From 506ab8caa5e7f8cae71331867a4b32dae4cf832b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 14 Mar 2011 08:08:39 -0700 Subject: [PATCH] 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 --- .../src/org/eclipse/jgit/pgm/Push.java | 12 +++++------ .../src/org/eclipse/jgit/api/PushCommand.java | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java index b6a10518a..83f1ee177 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java @@ -77,14 +77,10 @@ class Push extends TextBuiltin { private final List refSpecs = new ArrayList(); @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); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java index eefe401d1..d3512cc0c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java @@ -297,6 +297,26 @@ public class PushCommand extends GitCommand> { 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 */