I\'m trying to get my hands on the HEAD commit with JGit:
val builder = new FileRepositoryBuilder()
val repo = builder.setGitDir(new File(\"/www/test-repo\")
For me (using 4.5.0.201609210915-r) the solution was to use just RepositoryBuilder instead of FileRepositoryBuilder. Until I made this change all methods were returning null.
rb = new org.eclipse.jgit.lib.RepositoryBuilder()
.readEnvironment()
.findGitDir()
.build();
headRef = rb.getRef(rb.getFullBranch());
headHash = headRef.getObjectId().name();