Skip to content

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<div>
22
If checked, every build performs a fresh clone of the SCM rather than locking and updating a common copy.
33
No changelog will be computed.
4-
For Git, you are advised to select <b>Advanced clone behaviors » Shallow clone</b> to make the clone much faster.
4+
For Git, you are advised to add <b>Advanced clone behaviors</b>
5+
and then check <b>Shallow clone</b> and <b>Honor refspec on initial clone</b> and uncheck <b>Fetch tags</b>
6+
to make the clone much faster.
57
You may still enable <b>Cache fetched versions on controller for quick retrieval</b> if you prefer.
68
</div>

src/test/java/org/jenkinsci/plugins/workflow/libs/SCMSourceRetrieverTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import static hudson.ExtensionList.lookupSingleton;
6363
import hudson.plugins.git.extensions.impl.CloneOption;
6464
import jenkins.plugins.git.traits.CloneOptionTrait;
65+
import jenkins.plugins.git.traits.RefSpecsSCMSourceTrait;
6566
import jenkins.scm.api.trait.SCMSourceTrait;
6667
import static org.hamcrest.Matchers.contains;
6768
import 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, 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,8 @@ public static class BasicSCMSource extends SCMSource {
392395
r.assertLogContains("something special", b);
393396
r.assertLogContains("Deleted .git, README.md", b);
394397
r.assertLogContains("Using shallow clone with depth 1", b);
398+
r.assertLogContains("Avoid fetching tags", b);
399+
r.assertLogNotContains("+refs/heads/*:refs/remotes/origin/*", b);
395400
}
396401

397402
@Test public void cloneModeLibraryPath() throws Exception {

0 commit comments

Comments
 (0)