Skip to content

Commit

Permalink
[JENKINS-50287] allow to select two different behaviours for as-it-is…
Browse files Browse the repository at this point in the history
… checkout (#215)

* [JENKINS-50287] allow to select two different behaviours for as-it-is checkout
  • Loading branch information
kuisathaverat committed May 8, 2018
1 parent fc18211 commit 8903421
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/main/java/hudson/scm/SubversionSCM.java
Expand Up @@ -2975,8 +2975,10 @@ public SVNDepth getSvnDepthForUpdate() {
* @return {@link org.tmatesoft.svn.core.SVNDepth} value.
*/
public SVNDepth getSvnDepthForCheckout() {
if(getDepthOption().equals("unknown")) {
if("unknown".equals(getDepthOption())) {
return SVNDepth.FILES;
} else if ("as-it-is-infinity".equals(getDepthOption())){
return SVNDepth.INFINITY;
} else {
return getSvnDepth(getDepthOption());
}
Expand All @@ -2991,9 +2993,9 @@ public SVNDepth getSvnDepthForCheckout() {
* @return {@link org.tmatesoft.svn.core.SVNDepth} value.
*/
public SVNDepth getSvnDepthForRevert() {
if(getDepthOption().equals("unknown")) {
if("unknown".equals(getDepthOption()) || "as-it-is-infinity".equals(getDepthOption())){
return SVNDepth.INFINITY;
} else {
}else {
return getSvnDepth(getDepthOption());
}
}
Expand Down
Expand Up @@ -49,7 +49,8 @@ THE SOFTWARE.
<f:option value="empty" selected="${instance.depthOption=='empty'}">empty</f:option>
<f:option value="files" selected="${instance.depthOption=='files'}">files</f:option>
<f:option value="immediates" selected="${instance.depthOption=='immediates'}">immediates</f:option>
<f:option value="unknown" selected="${instance.depthOption=='unknown'}">as-it-is</f:option>
<f:option value="unknown" selected="${instance.depthOption=='unknown'}">as-it-is(checkout depth files)</f:option>
<f:option value="as-it-is-infinity" selected="${instance.depthOption=='as-it-is-infinity'}">as-it-is(checkout depth infinity)</f:option>
</select>
</f:entry>
<f:entry title="${%Ignore externals}" field="ignoreExternalsOption">
Expand Down
48 changes: 48 additions & 0 deletions src/test/java/jenkins/scm/impl/subversion/SubversionStepTest.java
Expand Up @@ -116,4 +116,52 @@ public void multipleSCMs() throws Exception {
assertFalse(iterator.hasNext());
}


@Test
public void checkoutDepthAsItIsInfiniteTest() throws Exception {
checkoutDepthTest("as-it-is-infinity");
}

@Test
public void checkoutDepthFilesTest() throws Exception {
checkoutDepthTest("files");
}

@Test
public void checkoutDepthUnknownTest() throws Exception {
checkoutDepthTest("unknown");
}

@Test
public void checkoutDepthEmptyTest() throws Exception {
checkoutDepthTest("empty");
}

@Test
public void checkoutDepthImmediatesTest() throws Exception {
checkoutDepthTest("immediates");
}

@Test
public void checkoutDepthInfinityTest() throws Exception {
checkoutDepthTest("infinity");
}

private void checkoutDepthTest(String depth) throws Exception {
sampleRepo.init();
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "checkoutAsItIsInfinite");
p.addTrigger(new SCMTrigger(""));
p.setQuietPeriod(3); // so it only does one build
p.setDefinition(new CpsFlowDefinition(
"node(){\n"
+ " ws {\n"
+ " dir('main'){\n"
+ " checkout([$class: 'SubversionSCM', locations: [[ depthOption: '" + depth + "', remote: '"
+ sampleRepo.trunkUrl() + "']]])\n"
+ " } \n"
+ " }\n"
+ "}"));
r.waitUntilNoActivity();
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
}
}

0 comments on commit 8903421

Please sign in to comment.