Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-45771] Ensure all command boolean options can be toggled, no…
…t just set once
  • Loading branch information
stephenc committed Jul 27, 2017
1 parent b0fa807 commit d224341
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 10 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
34 changes: 29 additions & 5 deletions src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
Expand Up @@ -433,12 +433,22 @@ public CloneCommand repositoryName(String name) {
}

public CloneCommand shared() {
return shared(true);
}

@Override
public CloneCommand shared(boolean shared) {
this.shared = true;
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 +1955,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 +2361,21 @@ 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
35 changes: 31 additions & 4 deletions src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java
Expand Up @@ -1307,11 +1307,23 @@ 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() {
return shared(true);
}

@Override
public CloneCommand shared(boolean shared) {
this.shared = true;
return this;
}
Expand Down Expand Up @@ -1755,7 +1767,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 +1875,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 d224341

Please sign in to comment.