Skip to content

Commit b6ad05e

Browse files
authored
Merge pull request #705 from git-commit-id/701
#701: Fix an issue with submodules
2 parents cd70b10 + 723e8c2 commit b6ad05e

File tree

5 files changed

+8
-342
lines changed

5 files changed

+8
-342
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<dependency>
6464
<groupId>${project.groupId}</groupId>
6565
<artifactId>git-commit-id-plugin-core</artifactId>
66-
<version>6.0.0-rc.6</version>
66+
<version>6.0.0-rc.7</version>
6767
</dependency>
6868
<dependency>
6969
<groupId>com.google.code.findbugs</groupId>

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

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,24 +1207,10 @@ public void error(String msg, Throwable t) {
12071207
return;
12081208
}
12091209

1210-
dotGitDirectory = lookupGitDirectory();
1211-
if (failOnNoGitDirectory && !directoryExists(dotGitDirectory)) {
1212-
throw new GitCommitIdExecutionException(
1213-
".git directory is not found! Please specify a valid [dotGitDirectory] in your"
1214-
+ " pom.xml");
1215-
}
1216-
12171210
if (gitDescribe == null) {
12181211
gitDescribe = new GitDescribeConfig();
12191212
}
12201213

1221-
if (dotGitDirectory != null) {
1222-
log.info("dotGitDirectory '" + dotGitDirectory.getAbsolutePath() + "'");
1223-
} else {
1224-
log.info("dotGitDirectory is null, aborting execution!");
1225-
return;
1226-
}
1227-
12281214
try {
12291215
commitIdGenerationModeEnum =
12301216
CommitIdGenerationMode.valueOf(commitIdGenerationMode.toUpperCase());
@@ -1411,6 +1397,11 @@ public Charset getPropertiesSourceCharset() {
14111397
public boolean shouldPropertiesEscapeUnicode() {
14121398
return generateGitPropertiesFileWithEscapedUnicode;
14131399
}
1400+
1401+
@Override
1402+
public boolean shouldFailOnNoGitDirectory() {
1403+
return failOnNoGitDirectory;
1404+
}
14141405
};
14151406

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

1506-
/**
1507-
* Find the git directory of the currently used project. If it's not already specified, this
1508-
* method will try to find it.
1509-
*
1510-
* @return the File representation of the .git directory
1511-
*/
1512-
private File lookupGitDirectory() throws GitCommitIdExecutionException {
1513-
return new GitDirLocator(project, reactorProjects).lookupGitDirectory(dotGitDirectory);
1514-
}
1515-
15161497
private void logProperties(LogInterface log, Properties propertiesToPublish) {
15171498
for (String propertyName : propertiesToPublish.stringPropertyNames()) {
15181499
log.info("including property '" + propertyName + "' in results");
@@ -1522,8 +1503,4 @@ private void logProperties(LogInterface log, Properties propertiesToPublish) {
15221503
private boolean isPomProject(@Nonnull MavenProject project) {
15231504
return project.getPackaging().equalsIgnoreCase("pom");
15241505
}
1525-
1526-
private boolean directoryExists(@Nullable File fileLocation) {
1527-
return fileLocation != null && fileLocation.exists() && fileLocation.isDirectory();
1528-
}
15291506
}

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

Lines changed: 0 additions & 183 deletions
This file was deleted.

src/test/java/pl/project13/maven/git/GitCommitIdMojoIntegrationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,8 @@ public void shouldSkipWithoutFailOnNoGitDirectoryWhenNoGitRepoFound(boolean useN
585585
mojo.execute();
586586

587587
// then
588-
assertThat(targetProject.getProperties()).isEmpty();
588+
assertThat(targetProject.getProperties().keySet()).containsOnly(
589+
"git.build.time", "git.build.version", "git.build.host");
589590
}
590591

591592
@Test

src/test/java/pl/project13/maven/git/GitDirLocatorTest.java

Lines changed: 0 additions & 129 deletions
This file was deleted.

0 commit comments

Comments
 (0)