Skip to content

Commit

Permalink
git-commit-id/git-commit-id-maven-plugin#701: add testcase to demonst…
Browse files Browse the repository at this point in the history
…rate the issue
  • Loading branch information
TheSnoozer committed Mar 2, 2024
1 parent 0dcee41 commit 49cee9c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/test/java/pl/project13/core/AvailableGitTestRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,41 @@ public enum AvailableGitTestRepo {
*/
WITH_COMMIT_THAT_HAS_TWO_TAGS("src/test/resources/_git_with_commit_that_has_two_tags"),
ON_A_TAG_DIRTY("src/test/resources/_git_on_a_tag_dirty"),
/**
* <pre>
* * 01ed93c - (11 years ago) any commit, just a readme - Konrad Malawski (HEAD -> master)
* * 4ce26eb - (11 years ago) my submodules, yay - Konrad Malawski
* </pre>
* <pre>
* $ git submodule status
* -9fd4b69a5ca09b60884d4f8f49ce16ea071077be module1
* -9fd4b69a5ca09b60884d4f8f49ce16ea071077be module2
* -9fd4b69a5ca09b60884d4f8f49ce16ea071077be module3
* -9fd4b69a5ca09b60884d4f8f49ce16ea071077be module4
*
* $ git config --file .gitmodules --get-regexp '\.url$'
* submodule.module1.url /tmp/module1
* submodule.module2.url /tmp/module1
* submodule.module3.url /tmp/module1
* submodule.module4.url /tmp/module1
* </pre>
*/
WITH_SUBMODULES("src/test/resources/_git_with_submodules"),

/**
* <pre>
* 6455ccd - (3 minutes ago) init (HEAD -> master)
* </pre>
* <pre>
* $ git submodule status
* 945bfe60e8a3eff168e915c7ba5bac37c9d0165b remote-module (heads/empty-branch)
*
* $ git submodule foreach --recursive git remote get-url origin
* Entering 'remote-module'
* [email protected]:git-commit-id/git-test-resources.git
* </pre>
*/
WITH_REMOTE_SUBMODULES("src/test/resources/_git_with_remote_submodules"),
/**
* <pre>
* b6a73ed - (HEAD, master) third addition (4 minutes ago) <p>Konrad Malawski</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,35 @@ public void shouldGeneratePropertiesWithMultiplePrefixesAndReactorProject(boolea
}
}

@Test
@Parameters(method = "useNativeGit")
public void shouldWorkWithRelativeSubmodules(boolean useNativeGit) throws Exception {
// given
File parentProjectDotGit =
createTmpDotGitDirectory(AvailableGitTestRepo.WITH_REMOTE_SUBMODULES);
File submoduleDotGitDirectory = parentProjectDotGit.getParentFile().toPath().resolve(
"remote-module").resolve(".git").toFile();
submoduleDotGitDirectory.getParentFile().mkdir();
Files.write(
submoduleDotGitDirectory.toPath(),
"gitdir: ../.git/modules/remote-module".getBytes()
);


GitCommitIdPlugin.Callback cb =
new GitCommitIdTestCallback()
.setDotGitDirectory(submoduleDotGitDirectory)
.setUseNativeGit(useNativeGit)
.build();
Properties properties = new Properties();

// when
GitCommitIdPlugin.runPlugin(cb, properties);

// then
assertPropertyPresentAndEqual(properties, "git.commit.id.abbrev", "945bfe6");
}

@Test
public void verifyAllowedCharactersForEvaluateOnCommit() {
Pattern p = GitCommitIdPlugin.allowedCharactersForEvaluateOnCommit;
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources
Submodule resources updated 54 files
+1 −0 _git_with_remote_submodules/COMMIT_EDITMSG
+1 −0 _git_with_remote_submodules/HEAD
+8 −0 _git_with_remote_submodules/config
+1 −0 _git_with_remote_submodules/description
+15 −0 _git_with_remote_submodules/hooks/applypatch-msg.sample
+24 −0 _git_with_remote_submodules/hooks/commit-msg.sample
+173 −0 _git_with_remote_submodules/hooks/fsmonitor-watchman.sample
+8 −0 _git_with_remote_submodules/hooks/post-update.sample
+14 −0 _git_with_remote_submodules/hooks/pre-applypatch.sample
+49 −0 _git_with_remote_submodules/hooks/pre-commit.sample
+13 −0 _git_with_remote_submodules/hooks/pre-merge-commit.sample
+53 −0 _git_with_remote_submodules/hooks/pre-push.sample
+169 −0 _git_with_remote_submodules/hooks/pre-rebase.sample
+24 −0 _git_with_remote_submodules/hooks/pre-receive.sample
+42 −0 _git_with_remote_submodules/hooks/prepare-commit-msg.sample
+78 −0 _git_with_remote_submodules/hooks/push-to-checkout.sample
+128 −0 _git_with_remote_submodules/hooks/update.sample
+ _git_with_remote_submodules/index
+6 −0 _git_with_remote_submodules/info/exclude
+1 −0 _git_with_remote_submodules/logs/HEAD
+1 −0 _git_with_remote_submodules/logs/refs/heads/master
+1 −0 _git_with_remote_submodules/modules/remote-module/HEAD
+15 −0 _git_with_remote_submodules/modules/remote-module/config
+1 −0 _git_with_remote_submodules/modules/remote-module/description
+15 −0 _git_with_remote_submodules/modules/remote-module/hooks/applypatch-msg.sample
+24 −0 _git_with_remote_submodules/modules/remote-module/hooks/commit-msg.sample
+173 −0 _git_with_remote_submodules/modules/remote-module/hooks/fsmonitor-watchman.sample
+8 −0 _git_with_remote_submodules/modules/remote-module/hooks/post-update.sample
+14 −0 _git_with_remote_submodules/modules/remote-module/hooks/pre-applypatch.sample
+49 −0 _git_with_remote_submodules/modules/remote-module/hooks/pre-commit.sample
+13 −0 _git_with_remote_submodules/modules/remote-module/hooks/pre-merge-commit.sample
+53 −0 _git_with_remote_submodules/modules/remote-module/hooks/pre-push.sample
+169 −0 _git_with_remote_submodules/modules/remote-module/hooks/pre-rebase.sample
+24 −0 _git_with_remote_submodules/modules/remote-module/hooks/pre-receive.sample
+42 −0 _git_with_remote_submodules/modules/remote-module/hooks/prepare-commit-msg.sample
+78 −0 _git_with_remote_submodules/modules/remote-module/hooks/push-to-checkout.sample
+128 −0 _git_with_remote_submodules/modules/remote-module/hooks/update.sample
+ _git_with_remote_submodules/modules/remote-module/index
+6 −0 _git_with_remote_submodules/modules/remote-module/info/exclude
+2 −0 _git_with_remote_submodules/modules/remote-module/logs/HEAD
+1 −0 _git_with_remote_submodules/modules/remote-module/logs/refs/heads/empty-branch
+1 −0 _git_with_remote_submodules/modules/remote-module/logs/refs/heads/master
+1 −0 _git_with_remote_submodules/modules/remote-module/logs/refs/remotes/origin/HEAD
+ ...with_remote_submodules/modules/remote-module/objects/pack/pack-d9286cd854d21f91ec99e39e2bd77b285b65369f.idx
+ ...ith_remote_submodules/modules/remote-module/objects/pack/pack-d9286cd854d21f91ec99e39e2bd77b285b65369f.pack
+3 −0 _git_with_remote_submodules/modules/remote-module/packed-refs
+1 −0 _git_with_remote_submodules/modules/remote-module/refs/heads/empty-branch
+1 −0 _git_with_remote_submodules/modules/remote-module/refs/heads/master
+1 −0 _git_with_remote_submodules/modules/remote-module/refs/remotes/origin/HEAD
+ _git_with_remote_submodules/objects/48/3af0b2862f9e7c6afc84d4cc4757dd7ecc1d7a
+ _git_with_remote_submodules/objects/64/55ccdd44935492173b2bb24061ea55deface15
+ _git_with_remote_submodules/objects/6c/c27180276224938bef4b8791d0f2131a2287e9
+ _git_with_remote_submodules/objects/71/a6c2eb9ca81d61e485f30509e03b98c6e276f2
+1 −0 _git_with_remote_submodules/refs/heads/master

0 comments on commit 49cee9c

Please sign in to comment.