Skip to content

Commit 49cee9c

Browse files
author
TheSnoozer
committed
git-commit-id/git-commit-id-maven-plugin#701: add testcase to demonstrate the issue
1 parent 0dcee41 commit 49cee9c

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

src/test/java/pl/project13/core/AvailableGitTestRepo.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,41 @@ public enum AvailableGitTestRepo {
4848
*/
4949
WITH_COMMIT_THAT_HAS_TWO_TAGS("src/test/resources/_git_with_commit_that_has_two_tags"),
5050
ON_A_TAG_DIRTY("src/test/resources/_git_on_a_tag_dirty"),
51+
/**
52+
* <pre>
53+
* * 01ed93c - (11 years ago) any commit, just a readme - Konrad Malawski (HEAD -> master)
54+
* * 4ce26eb - (11 years ago) my submodules, yay - Konrad Malawski
55+
* </pre>
56+
* <pre>
57+
* $ git submodule status
58+
* -9fd4b69a5ca09b60884d4f8f49ce16ea071077be module1
59+
* -9fd4b69a5ca09b60884d4f8f49ce16ea071077be module2
60+
* -9fd4b69a5ca09b60884d4f8f49ce16ea071077be module3
61+
* -9fd4b69a5ca09b60884d4f8f49ce16ea071077be module4
62+
*
63+
* $ git config --file .gitmodules --get-regexp '\.url$'
64+
* submodule.module1.url /tmp/module1
65+
* submodule.module2.url /tmp/module1
66+
* submodule.module3.url /tmp/module1
67+
* submodule.module4.url /tmp/module1
68+
* </pre>
69+
*/
5170
WITH_SUBMODULES("src/test/resources/_git_with_submodules"),
71+
72+
/**
73+
* <pre>
74+
* 6455ccd - (3 minutes ago) init (HEAD -> master)
75+
* </pre>
76+
* <pre>
77+
* $ git submodule status
78+
* 945bfe60e8a3eff168e915c7ba5bac37c9d0165b remote-module (heads/empty-branch)
79+
*
80+
* $ git submodule foreach --recursive git remote get-url origin
81+
* Entering 'remote-module'
82+
* git@github.com:git-commit-id/git-test-resources.git
83+
* </pre>
84+
*/
85+
WITH_REMOTE_SUBMODULES("src/test/resources/_git_with_remote_submodules"),
5286
/**
5387
* <pre>
5488
* b6a73ed - (HEAD, master) third addition (4 minutes ago) <p>Konrad Malawski</p>

src/test/java/pl/project13/core/GitCommitIdPluginIntegrationTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,35 @@ public void shouldGeneratePropertiesWithMultiplePrefixesAndReactorProject(boolea
15831583
}
15841584
}
15851585

1586+
@Test
1587+
@Parameters(method = "useNativeGit")
1588+
public void shouldWorkWithRelativeSubmodules(boolean useNativeGit) throws Exception {
1589+
// given
1590+
File parentProjectDotGit =
1591+
createTmpDotGitDirectory(AvailableGitTestRepo.WITH_REMOTE_SUBMODULES);
1592+
File submoduleDotGitDirectory = parentProjectDotGit.getParentFile().toPath().resolve(
1593+
"remote-module").resolve(".git").toFile();
1594+
submoduleDotGitDirectory.getParentFile().mkdir();
1595+
Files.write(
1596+
submoduleDotGitDirectory.toPath(),
1597+
"gitdir: ../.git/modules/remote-module".getBytes()
1598+
);
1599+
1600+
1601+
GitCommitIdPlugin.Callback cb =
1602+
new GitCommitIdTestCallback()
1603+
.setDotGitDirectory(submoduleDotGitDirectory)
1604+
.setUseNativeGit(useNativeGit)
1605+
.build();
1606+
Properties properties = new Properties();
1607+
1608+
// when
1609+
GitCommitIdPlugin.runPlugin(cb, properties);
1610+
1611+
// then
1612+
assertPropertyPresentAndEqual(properties, "git.commit.id.abbrev", "945bfe6");
1613+
}
1614+
15861615
@Test
15871616
public void verifyAllowedCharactersForEvaluateOnCommit() {
15881617
Pattern p = GitCommitIdPlugin.allowedCharactersForEvaluateOnCommit;

src/test/resources

Submodule resources updated 54 files

0 commit comments

Comments
 (0)