Improve reading repo information.
Relying on logs/HEAD in case of CI doesn't work.
This commit is contained in:
parent
2ed50a772e
commit
fda3ec4783
|
@ -84,8 +84,6 @@ Module {
|
||||||
|
|
||||||
property string tool: toolFilePath
|
property string tool: toolFilePath
|
||||||
property string theRepoDir: repoDir
|
property string theRepoDir: repoDir
|
||||||
property string filePath: FileInfo.joinPaths(metaDataBaseDir, "logs/HEAD")
|
|
||||||
property var timestamp: File.lastModified(filePath)
|
|
||||||
|
|
||||||
property string repoState
|
property string repoState
|
||||||
property string repoStateTag
|
property string repoStateTag
|
||||||
|
@ -93,8 +91,24 @@ Module {
|
||||||
property string repoStateRevision
|
property string repoStateRevision
|
||||||
|
|
||||||
configure: {
|
configure: {
|
||||||
if (!File.exists(filePath))
|
var commitsProbe = new Process();
|
||||||
return; // No commits yet.
|
try {
|
||||||
|
commitsProbe.setWorkingDirectory(theRepoDir);
|
||||||
|
var exitCode = commitsProbe.exec(tool, ["rev-list", "HEAD", "--count"], false);
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
console.info("Cannot read repo state.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var count = parseInt(commitsProbe.readStdOut().trim());
|
||||||
|
if (count < 1) {
|
||||||
|
console.info("The repo has no commits yet.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
commitsProbe.close();
|
||||||
|
}
|
||||||
|
|
||||||
var proc = new Process();
|
var proc = new Process();
|
||||||
try {
|
try {
|
||||||
proc.setWorkingDirectory(theRepoDir);
|
proc.setWorkingDirectory(theRepoDir);
|
||||||
|
@ -108,9 +122,14 @@ Module {
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
const tagSections = repoState.split("-");
|
const tagSections = repoState.split("-");
|
||||||
repoStateTag = tagSections[0];
|
|
||||||
repoStateDistance = tagSections[1];
|
if (tagSections.length >= 3) {
|
||||||
repoStateRevision = tagSections[2];
|
repoStateTag = tagSections[0];
|
||||||
|
repoStateDistance = tagSections[1];
|
||||||
|
repoStateRevision = tagSections[2];
|
||||||
|
} else {
|
||||||
|
repoStateRevision = tagSections[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
proc.close();
|
proc.close();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user