@@ -914,6 +914,73 @@ public void shouldGenerateClosestTagInformationWithIncludeLightweightTagsForClos
914914 assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.commit.count" , "1" );
915915 }
916916
917+ @ Test
918+ @ Parameters (method = "useNativeGit" )
919+ public void shouldGenerateClosestTagInformationWithIncludeLightweightTagsForClosestTagAndPreferAnnotatedTags (boolean useNativeGit ) throws Exception {
920+ // given
921+ mavenSandbox
922+ .withParentProject ("my-jar-project" , "jar" )
923+ .withNoChildProject ()
924+ .withGitRepoInParent (AvailableGitTestRepo .WITH_COMMIT_THAT_HAS_TWO_TAGS )
925+ .create ();
926+
927+ MavenProject targetProject = mavenSandbox .getParentProject ();
928+ setProjectToExecuteMojoIn (targetProject );
929+
930+ GitDescribeConfig gitDescribe = createGitDescribeConfig (true , 9 );
931+ gitDescribe .setDirty ("-customDirtyMark" );
932+ gitDescribe .setTags (true ); // include lightweight tags
933+
934+ mojo .setGitDescribe (gitDescribe );
935+ mojo .setUseNativeGit (useNativeGit );
936+
937+ // when
938+ mojo .execute ();
939+
940+ // then
941+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.abbrev" , "b6a73ed" );
942+
943+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.describe" , "newest-tag-1-gb6a73ed74-customDirtyMark" );
944+
945+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.name" , "newest-tag" );
946+
947+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.commit.count" , "1" );
948+ }
949+
950+ @ Test
951+ @ Parameters (method = "useNativeGit" )
952+ public void shouldGenerateClosestTagInformationWithIncludeLightweightTagsForClosestTagAndFilter (boolean useNativeGit ) throws Exception {
953+ // given
954+ mavenSandbox
955+ .withParentProject ("my-jar-project" , "jar" )
956+ .withNoChildProject ()
957+ .withGitRepoInParent (AvailableGitTestRepo .WITH_COMMIT_THAT_HAS_TWO_TAGS )
958+ .create ();
959+
960+ MavenProject targetProject = mavenSandbox .getParentProject ();
961+ setProjectToExecuteMojoIn (targetProject );
962+
963+ GitDescribeConfig gitDescribe = createGitDescribeConfig (true , 9 );
964+ gitDescribe .setDirty ("-customDirtyMark" );
965+ gitDescribe .setTags (true ); // include lightweight tags
966+ gitDescribe .setMatch ("light*" );
967+
968+ mojo .setGitDescribe (gitDescribe );
969+ mojo .setUseNativeGit (useNativeGit );
970+
971+ // when
972+ mojo .execute ();
973+
974+ // then
975+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.abbrev" , "b6a73ed" );
976+
977+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.commit.id.describe" , "lightweight-tag-1-gb6a73ed74-customDirtyMark" );
978+
979+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.name" , "lightweight-tag" );
980+
981+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.closest.tag.commit.count" , "1" );
982+ }
983+
917984 private GitDescribeConfig createGitDescribeConfig (boolean forceLongFormat , int abbrev ) {
918985 GitDescribeConfig gitDescribeConfig = new GitDescribeConfig ();
919986 gitDescribeConfig .setTags (true );
0 commit comments