use of org.locationtech.geogig.api.plumbing.SendPack.TransferableRef in project GeoGig by boundlessgeo.
the class PushOp method resolveRefs.
private List<TransferableRef> resolveRefs() {
List<TransferableRef> refsToPush = new ArrayList<>();
List<String> refSpecsArg = this.refSpecs;
if (refSpecsArg.isEmpty()) {
if (all) {
ImmutableSet<Ref> localRefs = getLocalRefs();
for (Ref ref : localRefs) {
String localRef = ref.getName();
String remoteRef = null;
boolean forceUpdate = false;
boolean delete = false;
refsToPush.add(new TransferableRef(localRef, remoteRef, forceUpdate, delete));
}
} else {
// push current branch
Ref currentBranch = resolveHeadTarget();
String localRef = currentBranch.getName();
String remoteRef = null;
boolean forceUpdate = false;
boolean delete = false;
refsToPush.add(new TransferableRef(localRef, remoteRef, forceUpdate, delete));
}
} else {
for (String refspec : refSpecsArg) {
String[] refs = refspec.split(":");
if (refs.length == 0) {
refs = new String[2];
refs[0] = resolveHeadTarget().getName();
refs[1] = null;
} else {
if (refs[0].startsWith("+")) {
refs[0] = refs[0].substring(1);
}
for (int i = 0; i < refs.length; i++) {
if (refs[i].trim().isEmpty()) {
refs[i] = null;
}
}
}
checkArgument(refs.length < 3, "Invalid refspec, please use [+][<localref>][:][<remoteref>].");
boolean force = refspec.startsWith("+");
String localrefspec = refs[0];
boolean delete = localrefspec == null;
String remoterefspec = refs[refs.length == 2 ? 1 : 0];
refsToPush.add(new TransferableRef(localrefspec, remoterefspec, force, delete));
}
}
return refsToPush;
}
use of org.locationtech.geogig.api.plumbing.SendPack.TransferableRef in project GeoGig by boundlessgeo.
the class PushOp method _call.
/**
* Executes the push operation.
*
* @return {@code null}
* @see org.locationtech.geogig.api.AbstractGeoGigOp#call()
*/
@Override
protected TransferSummary _call() {
final String remoteName = this.remoteName == null ? "origin" : this.remoteName;
final Remote remote = resolveRemote(remoteName);
final List<TransferableRef> refsToPush = resolveRefs();
SendPack sendPack = command(SendPack.class);
sendPack.setRemote(remote);
sendPack.setRefs(refsToPush);
sendPack.setProgressListener(getProgressListener());
TransferSummary result = sendPack.call();
return result;
}
Aggregations