in src/main/java/org/apache/maven/buildcache/CacheUtils.java [109:131]
public static Scm readGitInfo(MavenSession session) throws IOException {
final Scm scmCandidate = new Scm();
final Path gitDir = getMultimoduleRoot(session).resolve(".git");
if (Files.isDirectory(gitDir)) {
final Path headFile = gitDir.resolve("HEAD");
if (Files.exists(headFile)) {
String headRef = readFirstLine(headFile, "<missing branch>");
if (headRef.startsWith("ref: ")) {
String branch = trim(removeStart(headRef, "ref: "));
scmCandidate.setSourceBranch(branch);
final Path refPath = gitDir.resolve(branch);
if (Files.exists(refPath)) {
String revision = readFirstLine(refPath, "<missing revision>");
scmCandidate.setRevision(trim(revision));
}
} else {
scmCandidate.setSourceBranch(headRef);
scmCandidate.setRevision(headRef);
}
}
}
return scmCandidate;
}