@Test
@Parameters(method = "useNativeGit")
<<<<<<< HEAD
public void shouldExtractTagsOnGivenCommit(boolean useNativeGit) throws Exception {
// given
mavenSandbox
.withParentProject("my-jar-project", "jar")
.withNoChildProject()
.withGitRepoInParent(AvailableGitTestRepo.WITH_COMMIT_THAT_HAS_TWO_TAGS)
.create(CleanUp.CLEANUP_FIRST);
git("my-jar-project").reset().setMode(ResetCommand.ResetType.HARD).setRef("d37a598").call();
MavenProject targetProject = mavenSandbox.getParentProject();
setProjectToExecuteMojoIn(targetProject);
alterMojoSettings("gitDescribe", null);
alterMojoSettings("useNativeGit", useNativeGit);
// when
mojo.execute();
// then
Properties properties = targetProject.getProperties();
assertGitPropertiesPresentInProject(properties);
assertThat(properties).satisfies(new ContainsKeyCondition("git.tags"));
assertThat(properties.get("git.tags").toString()).doesNotContain("refs/tags/");
assertThat(Splitter.on(",").split(properties.get("git.tags").toString()))
.containsOnly("lightweight-tag", "newest-tag");
=======
public void runGitDescribeWithMatchOption(boolean useNativeGit) throws Exception {
// given
mavenSandbox.withParentProject("my-pom-project", "pom")
.withChildProject("my-jar-module", "jar")
.withGitRepoInChild(AvailableGitTestRepo.MAVEN_GIT_COMMIT_ID_PLUGIN)
.create(CleanUp.CLEANUP_FIRST);
MavenProject targetProject = mavenSandbox.getChildProject();
setProjectToExecuteMojoIn(targetProject);
Map gitTagMap = new HashMap();
gitTagMap.put("v2.1.8", "4f787aa37d5d9c06780278f0cf92553d304820a2");
gitTagMap.put("v2.1.9", "a9dba4a25b64ab288d90cd503785b830d2e189a2");
for (Map.Entry entry : gitTagMap.entrySet()) {
String gitDescribeMatchNeedle = entry.getKey();
String commitIdOfMatchNeedle = entry.getValue();
GitDescribeConfig gitDescribeConfig = new GitDescribeConfig();
gitDescribeConfig.setMatch(gitDescribeMatchNeedle);
alterMojoSettings("gitDescribe", gitDescribeConfig);
alterMojoSettings("useNativeGit", useNativeGit);
// when
mojo.execute();
// then
assertThat(targetProject.getProperties()).includes(entry("git.commit.id.describe", gitDescribeMatchNeedle));
assertThat(targetProject.getProperties().get("git.commit.id")).isNotEqualTo(commitIdOfMatchNeedle);
}
>>>>>>> 60cb9786273940d6a1b9310f8da4a839491ff51a
}
private GitDescribeConfig createGitDescribeConfig(boolean forceLongFormat, int abbrev) { |