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

Add support for repo sync --no-tags #27

Merged
merged 2 commits into from
Sep 25, 2015
Merged
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
2 changes: 1 addition & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Checkstyle configuration that checks coding conventions.
<module name="UnusedImports"/>
<module name="MethodLength"/>
<module name="ParameterNumber">
<property name="max" value="15"/>
<property name="max" value="16"/>
</module>
<module name="LineLength">
<property name="tabWidth" value="4"/>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.424</version><!-- which version of Hudson is this plugin built against? -->
<version>1.580.1</version><!-- which version of Hudson is this plugin built against? -->
</parent>

<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/hudson/plugins/repo/RepoScm.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.export.Exported;
Expand Down Expand Up @@ -92,6 +93,7 @@ public class RepoScm extends SCM implements Serializable {
private final boolean quiet;
private final boolean trace;
private final boolean showAllChanges;
private boolean noTags;

/**
* Returns the manifest repository URL.
Expand Down Expand Up @@ -245,6 +247,11 @@ public boolean isQuiet() {
*/
@Exported
public boolean isTrace() { return trace; }
/**
* Returns the value of noTags.
*/
@Exported
public boolean isNoTags() { return noTags; }

/**
* The constructor takes in user parameters and sets them. Each job using
Expand Down Expand Up @@ -328,6 +335,18 @@ public RepoScm(final String manifestRepositoryUrl,
this.repoUrl = Util.fixEmptyAndTrim(repoUrl);
}

/**
* Set noTags.
*
* @param noTags
* If this value is true, add the "--no-tags" option when
* executing "repo sync".
*/
@DataBoundSetter
public final void setNoTags(final boolean noTags) {
this.noTags = noTags;
}

@Override
public SCMRevisionState calcRevisionsFromBuild(
final AbstractBuild<?, ?> build, final Launcher launcher,
Expand Down Expand Up @@ -465,6 +484,10 @@ private int doSync(final Launcher launcher, final FilePath workspace,
if (jobs > 0) {
commands.add("--jobs=" + jobs);
}
if (isNoTags()) {
commands.add("--no-tags");
}

int returnCode =
launcher.launch().stdout(logger).pwd(workspace)
.cmds(commands).envs(env).join();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/repo/TagAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
package hudson.plugins.repo;

import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.scm.AbstractScmTagAction;

import org.kohsuke.stapler.export.ExportedBean;
Expand All @@ -42,7 +42,7 @@ public class TagAction extends AbstractScmTagAction {
* @param build
* Build which we are interested in tagging
*/
TagAction(final AbstractBuild<?, ?> build) {
TagAction(final Run<?, ?> build) {
super(build);
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/hudson/plugins/repo/RepoScm/config.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
<f:checkbox name="repo.quiet" checked="${h.defaultToTrue(scm.quiet)}" />
</f:entry>

<f:entry title="No tags" help="/plugin/repo/help-noTags.html">
<f:checkbox name="repo.noTags" checked="${scm.noTags}" />
</f:entry>

<f:entry title="Trace" help="/plugin/repo/help-trace.html">
<f:checkbox name="repo.trace" checked="${scm.trace}" />
</f:entry>
Expand Down
6 changes: 6 additions & 0 deletions src/main/webapp/help-noTags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div>
<p>
Don't fetch tags.
This is passed to repo as <code>repo sync <i>--no-tags</i></code>.
</p>
</div>