Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#701: Fix an issue with submodules #705

Merged
merged 5 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading