Skip to content

Commit

Permalink
Merge pull request #705 from git-commit-id/701
Browse files Browse the repository at this point in the history
#701: Fix an issue with submodules
  • Loading branch information
TheSnoozer authored Mar 4, 2024
2 parents cd70b10 + 723e8c2 commit b6ad05e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 342 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>git-commit-id-plugin-core</artifactId>
<version>6.0.0-rc.6</version>
<version>6.0.0-rc.7</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand Down
33 changes: 5 additions & 28 deletions src/main/java/pl/project13/maven/git/GitCommitIdMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -1207,24 +1207,10 @@ public void error(String msg, Throwable t) {
return;
}

dotGitDirectory = lookupGitDirectory();
if (failOnNoGitDirectory && !directoryExists(dotGitDirectory)) {
throw new GitCommitIdExecutionException(
".git directory is not found! Please specify a valid [dotGitDirectory] in your"
+ " pom.xml");
}

if (gitDescribe == null) {
gitDescribe = new GitDescribeConfig();
}

if (dotGitDirectory != null) {
log.info("dotGitDirectory '" + dotGitDirectory.getAbsolutePath() + "'");
} else {
log.info("dotGitDirectory is null, aborting execution!");
return;
}

try {
commitIdGenerationModeEnum =
CommitIdGenerationMode.valueOf(commitIdGenerationMode.toUpperCase());
Expand Down Expand Up @@ -1411,6 +1397,11 @@ public Charset getPropertiesSourceCharset() {
public boolean shouldPropertiesEscapeUnicode() {
return generateGitPropertiesFileWithEscapedUnicode;
}

@Override
public boolean shouldFailOnNoGitDirectory() {
return failOnNoGitDirectory;
}
};

GitCommitIdPlugin.runPlugin(cb, properties);
Expand Down Expand Up @@ -1503,16 +1494,6 @@ private void appendPropertiesToReactorProjects(LogInterface log, Properties prop
log.info("Added properties to '" + reactorProjects.size() + "' projects");
}

/**
* Find the git directory of the currently used project. If it's not already specified, this
* method will try to find it.
*
* @return the File representation of the .git directory
*/
private File lookupGitDirectory() throws GitCommitIdExecutionException {
return new GitDirLocator(project, reactorProjects).lookupGitDirectory(dotGitDirectory);
}

private void logProperties(LogInterface log, Properties propertiesToPublish) {
for (String propertyName : propertiesToPublish.stringPropertyNames()) {
log.info("including property '" + propertyName + "' in results");
Expand All @@ -1522,8 +1503,4 @@ private void logProperties(LogInterface log, Properties propertiesToPublish) {
private boolean isPomProject(@Nonnull MavenProject project) {
return project.getPackaging().equalsIgnoreCase("pom");
}

private boolean directoryExists(@Nullable File fileLocation) {
return fileLocation != null && fileLocation.exists() && fileLocation.isDirectory();
}
}
183 changes: 0 additions & 183 deletions src/main/java/pl/project13/maven/git/GitDirLocator.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ public void shouldSkipWithoutFailOnNoGitDirectoryWhenNoGitRepoFound(boolean useN
mojo.execute();

// then
assertThat(targetProject.getProperties()).isEmpty();
assertThat(targetProject.getProperties().keySet()).containsOnly(
"git.build.time", "git.build.version", "git.build.host");
}

@Test
Expand Down
129 changes: 0 additions & 129 deletions src/test/java/pl/project13/maven/git/GitDirLocatorTest.java

This file was deleted.

0 comments on commit b6ad05e

Please sign in to comment.