|
|
@ -1,4 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
|
|
|
|
* Copyright (C) 2010, Chris Aniszczyk <caniszczyk@gmail.com> |
|
|
|
* Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com> |
|
|
|
* Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com> |
|
|
|
* and other copyright owners as documented in the project's IP log. |
|
|
|
* 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.io.IOException; |
|
|
|
import java.text.MessageFormat; |
|
|
|
import java.text.MessageFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collection; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
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.Constants; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectReader; |
|
|
|
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.PushResult; |
|
|
|
import org.eclipse.jgit.transport.RefSpec; |
|
|
|
import org.eclipse.jgit.transport.RefSpec; |
|
|
|
import org.eclipse.jgit.transport.RemoteRefUpdate; |
|
|
|
import org.eclipse.jgit.transport.RemoteRefUpdate; |
|
|
|
|
|
|
|
import org.eclipse.jgit.transport.RemoteRefUpdate.Status; |
|
|
|
import org.eclipse.jgit.transport.Transport; |
|
|
|
import org.eclipse.jgit.transport.Transport; |
|
|
|
import org.eclipse.jgit.transport.URIish; |
|
|
|
import org.eclipse.jgit.transport.URIish; |
|
|
|
import org.eclipse.jgit.transport.RemoteRefUpdate.Status; |
|
|
|
|
|
|
|
import org.kohsuke.args4j.Argument; |
|
|
|
import org.kohsuke.args4j.Argument; |
|
|
|
import org.kohsuke.args4j.Option; |
|
|
|
import org.kohsuke.args4j.Option; |
|
|
|
|
|
|
|
|
|
|
@ -108,37 +110,21 @@ class Push extends TextBuiltin { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void run() throws Exception { |
|
|
|
protected void run() throws Exception { |
|
|
|
if (force) { |
|
|
|
Git git = new Git(db); |
|
|
|
final List<RefSpec> orig = new ArrayList<RefSpec>(refSpecs); |
|
|
|
PushCommand push = git.push(); |
|
|
|
refSpecs.clear(); |
|
|
|
push.setDryRun(dryRun); |
|
|
|
for (final RefSpec spec : orig) |
|
|
|
push.setForce(force); |
|
|
|
refSpecs.add(spec.setForceUpdate(true)); |
|
|
|
push.setProgressMonitor(new TextProgressMonitor()); |
|
|
|
} |
|
|
|
push.setReceivePack(receivePack); |
|
|
|
|
|
|
|
push.setRefSpecs(refSpecs); |
|
|
|
final List<Transport> transports; |
|
|
|
push.setRemote(remote); |
|
|
|
transports = Transport.openAll(db, remote, Transport.Operation.PUSH); |
|
|
|
push.setThin(thin); |
|
|
|
for (final Transport transport : transports) { |
|
|
|
push.setTimeout(timeout); |
|
|
|
if (0 <= timeout) |
|
|
|
Iterable<PushResult> results = push.call(); |
|
|
|
transport.setTimeout(timeout); |
|
|
|
for (PushResult result : results) { |
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectReader reader = db.newObjectReader(); |
|
|
|
ObjectReader reader = db.newObjectReader(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
printPushResult(reader, uri, result); |
|
|
|
printPushResult(reader, result.getURI(), result); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
reader.release(); |
|
|
|
reader.release(); |
|
|
|
} |
|
|
|
} |
|
|
|