6262import static hudson .ExtensionList .lookupSingleton ;
6363import hudson .plugins .git .extensions .impl .CloneOption ;
6464import jenkins .plugins .git .traits .CloneOptionTrait ;
65+ import jenkins .plugins .git .traits .RefSpecsSCMSourceTrait ;
6566import jenkins .scm .api .trait .SCMSourceTrait ;
6667import static org .hamcrest .Matchers .contains ;
6768import static org .hamcrest .Matchers .containsInAnyOrder ;
@@ -379,7 +380,9 @@ public static class BasicSCMSource extends SCMSource {
379380 sampleRepo .git ("add" , "." );
380381 sampleRepo .git ("commit" , "--message=init" );
381382 GitSCMSource src = new GitSCMSource (sampleRepo .toString ());
382- src .setTraits (List .<SCMSourceTrait >of (new CloneOptionTrait (new CloneOption (true , true , null , null ))));
383+ CloneOption cloneOption = new CloneOption (true , true , null , null );
384+ cloneOption .setHonorRefspec (true );
385+ src .setTraits (List .<SCMSourceTrait >of (new CloneOptionTrait (cloneOption ), new RefSpecsSCMSourceTrait ("+refs/heads/master:refs/remotes/origin/master" )));
383386 SCMSourceRetriever scm = new SCMSourceRetriever (src );
384387 LibraryConfiguration lc = new LibraryConfiguration ("echoing" , scm );
385388 lc .setIncludeInChangesets (false );
@@ -392,6 +395,7 @@ public static class BasicSCMSource extends SCMSource {
392395 r .assertLogContains ("something special" , b );
393396 r .assertLogContains ("Using shallow clone with depth 1" , b );
394397 r .assertLogContains ("Avoid fetching tags" , b );
398+ r .assertLogNotContains ("+refs/heads/*:refs/remotes/origin/*" , b );
395399 // Fails to reproduce presence of *.jar.tmp@tmp; probably specific to use of GIT_ASKPASS:
396400 assertThat (new File (b .getRootDir (), "libs" ).list (), arrayContaining (matchesPattern ("[0-9a-f]{64}[.]jar" )));
397401 }
0 commit comments