Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-30141] Option to choose if depth is sticky #134

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 34 additions & 11 deletions src/main/java/hudson/scm/SubversionSCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -2669,6 +2669,13 @@ public static final class ModuleLocation extends AbstractDescribableImpl<ModuleL
@Exported
public final String depthOption;

/**
* Make subversion depth sticky or not (use "--depth" or "--set-depth" option) for switch
* and update commands. Default value is "true" (sticky).
*/
@Exported
public boolean stickyDepth;

/**
* Flag to ignore subversion externals definitions.
*/
Expand All @@ -2686,7 +2693,7 @@ public static final class ModuleLocation extends AbstractDescribableImpl<ModuleL
*/
@Deprecated
public ModuleLocation(String remote, String local) {
this(remote, null, local, null, false);
this(remote, null, local, null, true, false);
}

/**
Expand All @@ -2701,36 +2708,42 @@ void setCredentialsId (final String id) {
*/
@Deprecated
public ModuleLocation(String remote, String local, String depthOption, boolean ignoreExternalsOption) {
this(remote,null,local,depthOption,ignoreExternalsOption);
this(remote,null,local,depthOption,true,ignoreExternalsOption);
}

@DataBoundConstructor
@Deprecated
public ModuleLocation(String remote, String credentialsId, String local, String depthOption, boolean ignoreExternalsOption) {
this(remote,credentialsId,local,depthOption,true,ignoreExternalsOption);
}

@DataBoundConstructor
public ModuleLocation(String remote, String credentialsId, String local, String depthOption, boolean stickyDepth, boolean ignoreExternalsOption) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binary compatibility issue. It's better to keep and deprecate the original constructor

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'm quite new to Java :-)
I've pushed a fix commit to my repository. Now, how is it customary to
proceed in such cases? Shall I open a new pull request?

On Wed, Sep 9, 2015 at 12:32 PM, Oleg Nenashev notifications@github.com
wrote:

In src/main/java/hudson/scm/SubversionSCM.java
#134 (comment)
:

     }

     @DataBoundConstructor
  •    public ModuleLocation(String remote, String credentialsId, String local, String depthOption, boolean ignoreExternalsOption) {
    
  •    public ModuleLocation(String remote, String credentialsId, String local, String depthOption, boolean stickyDepth, boolean ignoreExternalsOption) {
    

binary compatibility issue. It's better to keep and deprecate the original
constructor


Reply to this email directly or view it on GitHub
https://github.com/jenkinsci/subversion-plugin/pull/134/files#r39023278.

this.remote = Util.removeTrailingSlash(Util.fixNull(remote).trim());
this.credentialsId = credentialsId;
this.local = fixEmptyAndTrim(local);
this.depthOption = StringUtils.isEmpty(depthOption) ? SVNDepth.INFINITY.getName() : depthOption;
this.stickyDepth = stickyDepth;
this.ignoreExternalsOption = ignoreExternalsOption;
}

public ModuleLocation withRemote(String remote) {
return new ModuleLocation(remote, credentialsId, local, depthOption, ignoreExternalsOption);
return new ModuleLocation(remote, credentialsId, local, depthOption, true, ignoreExternalsOption);
}

public ModuleLocation withCredentialsId(String credentialsId) {
return new ModuleLocation(remote, credentialsId, local, depthOption, ignoreExternalsOption);
return new ModuleLocation(remote, credentialsId, local, depthOption, true, ignoreExternalsOption);
}

public ModuleLocation withLocal(String local) {
return new ModuleLocation(remote, credentialsId, local, depthOption, ignoreExternalsOption);
return new ModuleLocation(remote, credentialsId, local, depthOption, true, ignoreExternalsOption);
}

public ModuleLocation withDepthOption(String depthOption) {
return new ModuleLocation(remote, credentialsId, local, depthOption, ignoreExternalsOption);
return new ModuleLocation(remote, credentialsId, local, depthOption, true, ignoreExternalsOption);
}

public ModuleLocation withIgnoreExternalsOption(boolean ignoreExternalsOption) {
return new ModuleLocation(remote, credentialsId, local, depthOption, ignoreExternalsOption);
return new ModuleLocation(remote, credentialsId, local, depthOption, true, ignoreExternalsOption);
}

/**
Expand Down Expand Up @@ -2894,6 +2907,15 @@ public String getDepthOption() {
return depthOption;
}

/**
* Determines if chosen depth shall be set to sticky or not.
*
* @return true if depth shall be sticky.
*/
public boolean isDepthSticky() {
return stickyDepth;
}

/**
* Determines if subversion externals definitions should be ignored.
*
Expand Down Expand Up @@ -2924,7 +2946,7 @@ public ModuleLocation getExpandedLocation(AbstractBuild<?, ?> build) {
*/
public ModuleLocation getExpandedLocation(EnvVars env) {
return new ModuleLocation(env.expand(remote), credentialsId, env.expand(getLocalDir()), getDepthOption(),
isIgnoreExternalsOption());
isDepthSticky(), isIgnoreExternalsOption());
}

@Override
Expand Down Expand Up @@ -2955,7 +2977,7 @@ public static List<ModuleLocation> parse(String[] remoteLocations, String[] cred
modules.add(new ModuleLocation(remoteLoc,
credentialIds != null && credentialIds.length > i ? credentialIds[i] : null,
Util.nullify(localLocations[i]),
depthOptions != null ? depthOptions[i] : null,
depthOptions != null ? depthOptions[i] : null, true,
isIgnoreExternals != null && isIgnoreExternals[i]));
}
}
Expand Down Expand Up @@ -2990,7 +3012,8 @@ public ModuleLocation getExpandedLocation(Job<?, ?> project) {
}
}

return new ModuleLocation(returnURL, credentialsId, getLocalDir(), getDepthOption(), isIgnoreExternalsOption());
return new ModuleLocation(returnURL, credentialsId, getLocalDir(), getDepthOption(),
isDepthSticky(), isIgnoreExternalsOption());
}

@Extension
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/scm/subversion/UpdateUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ public List<External> perform() throws IOException, InterruptedException {
switch (svnCommand) {
case UPDATE:
listener.getLogger().println("Updating " + location.remote + " at revision " + revisionName);
svnuc.doUpdate(local.getCanonicalFile(), r, svnDepth, true, true);
svnuc.doUpdate(local.getCanonicalFile(), r, svnDepth, true, location.isDepthSticky());
break;
case SWITCH:
listener.getLogger().println("Switching to " + location.remote + " at revision " + revisionName);
svnuc.doSwitch(local.getCanonicalFile(), location.getSVNURL(), r, r, svnDepth, true, true, true);
svnuc.doSwitch(local.getCanonicalFile(), location.getSVNURL(), r, r, svnDepth, true, location.isDepthSticky(), true);
break;
case CHECKOUT:
// This case is handled by the (svnCommand == SvnCommandToUse.CHECKOUT) above.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ THE SOFTWARE.
<f:option value="unknown" selected="${instance.depthOption=='unknown'}">as-it-is</f:option>
</select>
</f:entry>
<f:entry title="${%Make depth sticky}" field="stickyDepth">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also create a help file for this new option?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Done :-)

<f:checkbox default="true"/>
</f:entry>
<f:entry title="${%Ignore externals}" field="ignoreExternalsOption">
<f:checkbox default="true"/>
</f:entry>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
Choose if <code>--set-depth</code> (sticky) or <code>--depth</code> (non-sticky) option should be used for switch and update commands. Default value is sticky.
More information can be found
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vvv444 Please, use <code> instead of <tt>. I'll try to merge this PR soon.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

<a href="http://svnbook.red-bean.com/en/1.7/svn.advanced.sparsedirs.html" target="_blank">here</a>.
</div>