Browse Source

Update Push to use latest API

Change-Id: I57ea8634a46472f40046f4ec69de505abbf5f6cf
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
stable-0.10
Chris Aniszczyk 14 years ago
parent
commit
782dbfc60f
  1. 48
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java

48
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();
}

Loading…
Cancel
Save