aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src
diff options
context:
space:
mode:
authorChris Aniszczyk <caniszczyk@gmail.com>2010-10-10 15:55:03 -0500
committerChris Aniszczyk <caniszczyk@gmail.com>2010-10-10 15:55:03 -0500
commit782dbfc60f01021e29d31ac5189eed77c55583ab (patch)
tree27e36aa2daddc5944b3b394bcbf9343db368e95a /org.eclipse.jgit.pgm/src
parentae22630bd84022b495196c4deccc76a346b9a3a1 (diff)
downloadjgit-782dbfc60f01021e29d31ac5189eed77c55583ab.tar.gz
jgit-782dbfc60f01021e29d31ac5189eed77c55583ab.zip
Update Push to use latest API
Change-Id: I57ea8634a46472f40046f4ec69de505abbf5f6cf Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java48
1 files changed, 17 insertions, 31 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 05966416cc..b6a10518a5 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
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2010, Chris Aniszczyk <caniszczyk@gmail.com>
* Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
* and other copyright owners as documented in the project's IP log.
*
@@ -46,9 +47,10 @@ package org.eclipse.jgit.pgm;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.PushCommand;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
@@ -57,9 +59,9 @@ import org.eclipse.jgit.lib.TextProgressMonitor;
import org.eclipse.jgit.transport.PushResult;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteRefUpdate;
+import org.eclipse.jgit.transport.RemoteRefUpdate.Status;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.transport.RemoteRefUpdate.Status;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@@ -108,37 +110,21 @@ class Push extends TextBuiltin {
@Override
protected void run() throws Exception {
- if (force) {
- final List<RefSpec> orig = new ArrayList<RefSpec>(refSpecs);
- refSpecs.clear();
- for (final RefSpec spec : orig)
- refSpecs.add(spec.setForceUpdate(true));
- }
-
- final List<Transport> transports;
- transports = Transport.openAll(db, remote, Transport.Operation.PUSH);
- for (final Transport transport : transports) {
- if (0 <= timeout)
- transport.setTimeout(timeout);
- transport.setPushThin(thin);
- if (receivePack != null)
- transport.setOptionReceivePack(receivePack);
- transport.setDryRun(dryRun);
-
- final Collection<RemoteRefUpdate> toPush = transport
- .findRemoteRefUpdatesFor(refSpecs);
-
- final URIish uri = transport.getURI();
- final PushResult result;
- try {
- result = transport.push(new TextProgressMonitor(), toPush);
- } finally {
- transport.close();
- }
-
+ Git git = new Git(db);
+ PushCommand push = git.push();
+ push.setDryRun(dryRun);
+ push.setForce(force);
+ push.setProgressMonitor(new TextProgressMonitor());
+ push.setReceivePack(receivePack);
+ push.setRefSpecs(refSpecs);
+ push.setRemote(remote);
+ push.setThin(thin);
+ push.setTimeout(timeout);
+ Iterable<PushResult> results = push.call();
+ for (PushResult result : results) {
ObjectReader reader = db.newObjectReader();
try {
- printPushResult(reader, uri, result);
+ printPushResult(reader, result.getURI(), result);
} finally {
reader.release();
}