Skip to content

Commit b5740b7

Browse files
author
S L
committed
Avoid NPE as discussed in #57
1 parent 4e28dbf commit b5740b7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/pl/project13/maven/git/JGitProvider.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,16 @@ protected String getBuildAuthorEmail() {
8383
protected void prepareGitToExtractMoreDetailedReproInformation() throws MojoExecutionException {
8484
try {
8585
// more details parsed out bellow
86-
Ref HEAD = git.getRef(Constants.HEAD);
87-
if (HEAD == null) {
86+
Ref head = git.getRef(Constants.HEAD);
87+
if (head == null) {
8888
throw new MojoExecutionException("Could not get HEAD Ref, are you sure you've set the dotGitDirectory property of this plugin to a valid path?");
8989
}
9090
revWalk = new RevWalk(git);
91-
headCommit = revWalk.parseCommit(HEAD.getObjectId());
91+
ObjectId headObjectId = head.getObjectId();
92+
if(headObjectId == null){
93+
throw new MojoExecutionException("Could not get HEAD Ref, are you sure you've some commits in the dotGitDirectory?");
94+
}
95+
headCommit = revWalk.parseCommit(headObjectId);
9296
revWalk.markStart(headCommit);
9397
} catch (MojoExecutionException e) {
9498
throw e;

0 commit comments

Comments
 (0)