Skip to content

Commit 9dfd3e2

Browse files
author
TheSnoozer
committed
#339: Adding another test case for extracting tags (pretty much the default where the repository is not in detached state and HEAD is tagged
1 parent 263fcde commit 9dfd3e2

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,35 @@ public void shouldExtractTagsOnGivenCommitWithOldestCommit(boolean useNativeGit)
923923
.containsOnly("annotated-tag", "lightweight-tag", "newest-tag");
924924
}
925925

926+
@Test
927+
@Parameters(method = "useNativeGit")
928+
public void shouldExtractTagsOnHead(boolean useNativeGit) throws Exception {
929+
// given
930+
mavenSandbox.withParentProject("my-jar-project", "jar")
931+
.withNoChildProject()
932+
.withGitRepoInParent(AvailableGitTestRepo.ON_A_TAG)
933+
.create();
934+
935+
MavenProject targetProject = mavenSandbox.getParentProject();
936+
setProjectToExecuteMojoIn(targetProject);
937+
938+
mojo.setGitDescribe(null);
939+
mojo.setUseNativeGit(useNativeGit);
940+
941+
// when
942+
mojo.execute();
943+
944+
// then
945+
Properties properties = targetProject.getProperties();
946+
assertGitPropertiesPresentInProject(properties);
947+
948+
assertThat(properties).satisfies(new ContainsKeyCondition("git.tags"));
949+
assertThat(properties.get("git.tags").toString()).doesNotContain("refs/tags/");
950+
951+
assertThat(Splitter.on(",").split(properties.get("git.tags").toString()))
952+
.containsOnly("v1.0.0");
953+
}
954+
926955
@Test
927956
@Parameters(method = "useNativeGit")
928957
public void runGitDescribeWithMatchOption(boolean useNativeGit) throws Exception {

0 commit comments

Comments
 (0)