Browse Source

PushCommand: Add utilities for --all, --tags

The --all flag on the command line implies using refs/heads/* as
a push specification. Add this to the standard command object.

The --tags flag on the command line implies using refs/tags/* as
a push specification. Add this to the standard command object.

Change-Id: Iaef200b17cce77604548dbfb15cf2499b10687b5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.12
Shawn O. Pearce 14 years ago committed by Chris Aniszczyk
parent
commit
506ab8caa5
  1. 12
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
  2. 20
      org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java

12
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java

@ -77,14 +77,10 @@ class Push extends TextBuiltin {
private final List<RefSpec> refSpecs = new ArrayList<RefSpec>();
@Option(name = "--all")
void addAll(final boolean ignored) {
refSpecs.add(Transport.REFSPEC_PUSH_ALL);
}
private boolean all;
@Option(name = "--tags")
void addTags(final boolean ignored) {
refSpecs.add(Transport.REFSPEC_TAGS);
}
private boolean tags;
@Option(name = "--verbose", aliases = { "-v" })
private boolean verbose = false;
@ -117,6 +113,10 @@ class Push extends TextBuiltin {
push.setProgressMonitor(new TextProgressMonitor());
push.setReceivePack(receivePack);
push.setRefSpecs(refSpecs);
if (all)
push.setPushAll();
if (tags)
push.setPushTags();
push.setRemote(remote);
push.setThin(thin);
push.setTimeout(timeout);

20
org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java

@ -297,6 +297,26 @@ public class PushCommand extends GitCommand<Iterable<PushResult>> {
return this;
}
/**
* Push all branches under refs/heads/*.
*
* @return {code this}
*/
public PushCommand setPushAll() {
refSpecs.add(Transport.REFSPEC_PUSH_ALL);
return this;
}
/**
* Push all tags under refs/tags/*.
*
* @return {code this}
*/
public PushCommand setPushTags() {
refSpecs.add(Transport.REFSPEC_TAGS);
return this;
}
/**
* @return the dry run preference for the push operation
*/

Loading…
Cancel
Save