Skip to content

Commit dcf951a

Browse files
authored
Version info includes whether the git repo is dirty
1 parent 2137613 commit dcf951a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2713,13 +2713,19 @@ private String getCheckerVersion() {
27132713
throw new BugInCF("Could not find the version in git.properties");
27142714
}
27152715
String branch = gitProperties.getProperty("git.branch");
2716-
if (version.endsWith("-SNAPSHOT") || !branch.equals("master")) {
2716+
// git.dirty indicates modified tracked files and staged changes. Untracked content doesn't
2717+
// count, so not being dirty doesn't mean that exactly the printed commit is being run.
2718+
String dirty = gitProperties.getProperty("git.dirty");
2719+
if (version.endsWith("-SNAPSHOT") || !branch.equals("master") || dirty.equals("true")) {
27172720
// Sometimes the branch is HEAD, which is not informative.
27182721
// How does that happen, and how can I fix it?
27192722
version += ", branch " + branch;
27202723
// For brevity, only date but not time of day.
27212724
version += ", " + gitProperties.getProperty("git.commit.time").substring(0, 10);
27222725
version += ", commit " + gitProperties.getProperty("git.commit.id.abbrev");
2726+
if (dirty.equals("true")) {
2727+
version += ", dirty=true";
2728+
}
27232729
}
27242730
return version;
27252731
}

0 commit comments

Comments
 (0)