33
33
import java .util .Map ;
34
34
import java .util .Properties ;
35
35
import java .util .TimeZone ;
36
+ import java .util .stream .Stream ;
36
37
import org .apache .maven .plugin .MojoExecutionException ;
37
38
import org .apache .maven .project .MavenProject ;
38
39
import org .codehaus .plexus .util .FileUtils ;
39
40
import org .eclipse .jgit .api .Git ;
40
41
import org .eclipse .jgit .api .ResetCommand ;
41
42
import org .junit .jupiter .params .ParameterizedTest ;
43
+ import org .junit .jupiter .params .provider .Arguments ;
42
44
import org .junit .jupiter .params .provider .MethodSource ;
43
45
import pl .project13 .core .CommitIdPropertiesOutputFormat ;
44
46
import pl .project13 .core .git .GitDescribeConfig ;
@@ -237,9 +239,20 @@ public void shouldSkipDescribeWhenConfiguredToDoSo(boolean useNativeGit) throws
237
239
.satisfies (new DoesNotContainKeyCondition ("git.commit.id.describe" ));
238
240
}
239
241
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
+
240
253
@ ParameterizedTest
241
- @ MethodSource ("useNativeGit " )
242
- public void shouldNotUseBuildEnvironmentBranchInfoWhenParameterSet (boolean useNativeGit )
254
+ @ MethodSource ("useNativeGitWithBranches " )
255
+ public void shouldNotUseBuildEnvironmentBranchInfoWhenParameterSet (boolean useNativeGit , String branchName )
243
256
throws Exception {
244
257
mavenSandbox
245
258
.withParentProject ("my-jar-project" , "jar" )
@@ -262,14 +275,14 @@ public void shouldNotUseBuildEnvironmentBranchInfoWhenParameterSet(boolean useNa
262
275
// reset repo and force detached HEAD
263
276
try (final Git git = git ("my-jar-project" )) {
264
277
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 ();
266
279
}
267
280
268
281
// when
269
282
mojo .execute ();
270
283
271
284
// then
272
- assertPropertyPresentAndEqual (targetProject .getProperties (), "git.branch" , "test_branch" );
285
+ assertPropertyPresentAndEqual (targetProject .getProperties (), "git.branch" , branchName );
273
286
}
274
287
275
288
@ ParameterizedTest
0 commit comments