Skip to content

Commit

Permalink
Merge pull request #255 from stephenc/jenkins-45771
Browse files Browse the repository at this point in the history
[JENKINS-45771] Ensure all command boolean options can be toggled, not just set once
  • Loading branch information
MarkEWaite committed Jul 27, 2017
2 parents b0fa807 + f445161 commit d7ed207
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -10,7 +10,7 @@

<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git-client</artifactId>
<version>2.4.7-SNAPSHOT</version>
<version>2.5.0-SNAPSHOT</version>
<packaging>hpi</packaging>

<name>Jenkins Git client plugin</name>
Expand Down
43 changes: 36 additions & 7 deletions src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
Expand Up @@ -296,7 +296,11 @@ public FetchCommand tags(boolean tags) {
}

public FetchCommand prune() {
this.prune = true;
return prune(true);
}

public FetchCommand prune(boolean prune) {
this.prune = prune;
return this;
}

Expand Down Expand Up @@ -433,12 +437,22 @@ public CloneCommand repositoryName(String name) {
}

public CloneCommand shared() {
this.shared = true;
return shared(true);
}

@Override
public CloneCommand shared(boolean shared) {
this.shared = shared;
return this;
}

public CloneCommand shallow() {
this.shallow = true;
return shallow(true);
}

@Override
public CloneCommand shallow(boolean shallow) {
this.shallow = shallow;
return this;
}

Expand Down Expand Up @@ -1945,7 +1959,12 @@ public PushCommand ref(String refspec) {
}

public PushCommand force() {
this.force = true;
return force(true);
}

@Override
public PushCommand force(boolean force) {
this.force = force;
return this;
}

Expand Down Expand Up @@ -2346,12 +2365,22 @@ public RevListCommand revList_() {
public List<ObjectId> out;

public RevListCommand all() {
this.all = true;
return this;
return all(true);
}

@Override
public RevListCommand all(boolean all) {
this.all = all;
return this;
}

public RevListCommand firstParent() {
this.firstParent = true;
return firstParent(true);
}

@Override
public RevListCommand firstParent(boolean firstParent) {
this.firstParent = firstParent;
return this;
}

Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/jenkinsci/plugins/gitclient/CloneCommand.java
Expand Up @@ -32,17 +32,41 @@ public interface CloneCommand extends GitCommand {
* shallow clone is controlled by the #depth method.
*
* @return a {@link org.jenkinsci.plugins.gitclient.CloneCommand} object.
* @deprecated favour {@link #shallow(boolean)}
*/
@Deprecated
CloneCommand shallow();

/**
* Only clone the most recent history, not preceding history. Depth of the
* shallow clone is controlled by the #depth method.
*
* @param shallow boolean controlling whether the clone is shallow
* @return a {@link org.jenkinsci.plugins.gitclient.CloneCommand} object.
* @since 2.5.0
*/
CloneCommand shallow(boolean shallow);

/**
* When the repository to clone is on the local machine, instead of using hard links, automatically setup
* .git/objects/info/alternates to share the objects with the source repository
*
* @return a {@link org.jenkinsci.plugins.gitclient.CloneCommand} object.
* @deprecated favour {@link #shared(boolean)}
*/
@Deprecated
CloneCommand shared();

/**
* When the repository to clone is on the local machine, instead of using hard links, automatically setup
* .git/objects/info/alternates to share the objects with the source repository
*
* @param shared boolean controlling whether the clone is shared
* @return a {@link org.jenkinsci.plugins.gitclient.CloneCommand} object.
* @since 2.5.0
*/
CloneCommand shared(boolean shared);

/**
* reference.
*
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/jenkinsci/plugins/gitclient/FetchCommand.java
Expand Up @@ -25,9 +25,20 @@ public interface FetchCommand extends GitCommand {
* prune.
*
* @return a {@link org.jenkinsci.plugins.gitclient.FetchCommand} object.
* @deprecated favour {@link #prune(boolean)}
*/
@Deprecated
FetchCommand prune();

/**
* prune.
*
* @param prune {@code true} if the fetch should prune.
* @return a {@link org.jenkinsci.plugins.gitclient.FetchCommand} object.
* @since 2.5.0
*/
FetchCommand prune(boolean prune);

/**
* shallow.
*
Expand Down
44 changes: 38 additions & 6 deletions src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java
Expand Up @@ -541,7 +541,12 @@ public org.jenkinsci.plugins.gitclient.FetchCommand from(URIish remote, List<Ref
}

public org.jenkinsci.plugins.gitclient.FetchCommand prune() {
shouldPrune = true;
return prune(true);
}

@Override
public org.jenkinsci.plugins.gitclient.FetchCommand prune(boolean prune) {
shouldPrune = prune;
return this;
}

Expand Down Expand Up @@ -1307,12 +1312,24 @@ public CloneCommand repositoryName(String name) {
}

public CloneCommand shallow() {
listener.getLogger().println("[WARNING] JGit doesn't support shallow clone. This flag is ignored");
return shallow(true);
}

@Override
public CloneCommand shallow(boolean shallow) {
if (shallow) {
listener.getLogger().println("[WARNING] JGit doesn't support shallow clone. This flag is ignored");
}
return this;
}

public CloneCommand shared() {
this.shared = true;
return shared(true);
}

@Override
public CloneCommand shared(boolean shared) {
this.shared = shared;
return this;
}

Expand Down Expand Up @@ -1755,7 +1772,12 @@ public PushCommand ref(String refspec) {
}

public PushCommand force() {
this.force = true;
return force(true);
}

@Override
public PushCommand force(boolean force) {
this.force = force;
return this;
}

Expand Down Expand Up @@ -1858,12 +1880,22 @@ public RevListCommand revList_()
public List<ObjectId> out;

public RevListCommand all() {
this.all = true;
return all(true);
}

@Override
public RevListCommand all(boolean all) {
this.all = all;
return this;
}

public RevListCommand firstParent() {
this.firstParent = true;
return firstParent(true);
}

@Override
public RevListCommand firstParent(boolean firstParent) {
this.firstParent = firstParent;
return this;
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/jenkinsci/plugins/gitclient/PushCommand.java
Expand Up @@ -32,9 +32,20 @@ public interface PushCommand extends GitCommand {
* force.
*
* @return a {@link org.jenkinsci.plugins.gitclient.PushCommand} object.
* @deprecated favour {@link #force(boolean)}
*/
@Deprecated
PushCommand force();

/**
* force.
*
* @param force {@code true} if the push should be forced
* @return a {@link org.jenkinsci.plugins.gitclient.PushCommand} object.
* @since 2.5.0
*/
PushCommand force(boolean force);

/**
* tags.
*
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/org/jenkinsci/plugins/gitclient/RevListCommand.java
Expand Up @@ -13,16 +13,38 @@ public interface RevListCommand extends GitCommand {
* all.
*
* @return a {@link org.jenkinsci.plugins.gitclient.RevListCommand} object.
* @deprecated favour {@link #all(boolean)}
*/
@Deprecated
RevListCommand all();

/**
* all.
*
* @param all {@code true} to list all.
* @return a {@link org.jenkinsci.plugins.gitclient.RevListCommand} object.
* @since 2.5.0
*/
RevListCommand all(boolean all);

/**
* firstParent.
*
* @return a {@link org.jenkinsci.plugins.gitclient.RevListCommand} object.
* @deprecated favour {@link #firstParent(boolean)}
*/
@Deprecated
RevListCommand firstParent();

/**
* firstParent.
*
* @param firstParent {@code true} to list first parent
* @return a {@link org.jenkinsci.plugins.gitclient.RevListCommand} object.
* @since 2.5.0
*/
RevListCommand firstParent(boolean firstParent);

/**
* to.
*
Expand Down

0 comments on commit d7ed207

Please sign in to comment.