3333import java .util .Map ;
3434import java .util .Properties ;
3535import java .util .TimeZone ;
36+ import java .util .stream .Stream ;
3637import org .apache .maven .plugin .MojoExecutionException ;
3738import org .apache .maven .project .MavenProject ;
3839import org .codehaus .plexus .util .FileUtils ;
3940import org .eclipse .jgit .api .Git ;
4041import org .eclipse .jgit .api .ResetCommand ;
4142import org .junit .jupiter .params .ParameterizedTest ;
43+ import org .junit .jupiter .params .provider .Arguments ;
4244import org .junit .jupiter .params .provider .MethodSource ;
4345import pl .project13 .core .CommitIdPropertiesOutputFormat ;
4446import pl .project13 .core .git .GitDescribeConfig ;
@@ -237,9 +239,20 @@ public void shouldSkipDescribeWhenConfiguredToDoSo(boolean useNativeGit) throws
237239 .satisfies (new DoesNotContainKeyCondition ("git.commit.id.describe" ));
238240 }
239241
242+ static Stream <Arguments > useNativeGitWithBranches () {
243+ return useNativeGit ().flatMap (arg ->
244+ Stream .of (
245+ "test_branch" ,
246+ "feature/my-git-branch"
247+ ).map (str ->
248+ Arguments .of (arg .get ()[0 ], str )
249+ )
250+ );
251+ }
252+
240253 @ ParameterizedTest
241- @ MethodSource ("useNativeGit " )
242- public void shouldNotUseBuildEnvironmentBranchInfoWhenParameterSet (boolean useNativeGit )
254+ @ MethodSource ("useNativeGitWithBranches " )
255+ public void shouldNotUseBuildEnvironmentBranchInfoWhenParameterSet (boolean useNativeGit , String branchName )
243256 throws Exception {
244257 mavenSandbox
245258 .withParentProject ("my-jar-project" , "jar" )
@@ -262,14 +275,14 @@ public void shouldNotUseBuildEnvironmentBranchInfoWhenParameterSet(boolean useNa
262275 // reset repo and force detached HEAD
263276 try (final Git git = git ("my-jar-project" )) {
264277 git .reset ().setMode (ResetCommand .ResetType .HARD ).setRef ("b6a73ed" ).call ();
265- git .checkout ().setCreateBranch (true ).setName ("test_branch" ).setForceRefUpdate (true ).call ();
278+ git .checkout ().setCreateBranch (true ).setName (branchName ).setForceRefUpdate (true ).call ();
266279 }
267280
268281 // when
269282 mojo .execute ();
270283
271284 // then
272- assertPropertyPresentAndEqual (targetProject .getProperties (), "git.branch" , "test_branch" );
285+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.branch" , branchName );
273286 }
274287
275288 @ ParameterizedTest
0 commit comments