private @Nullable Ref convertToRemote(@Nullable Ref remoteLocalRef) { Ref localRemoteRef = null; if (remoteLocalRef != null && !remoteLocalRef.getObjectId().isNull()) { // converd local refs namespaces to remotes namespace localRemoteRef = command(MapRef.class)// .setRemote(remote)// .add(remoteLocalRef)// .convertToRemote()// .call()// .get(0); } return localRemoteRef; }
@Override protected List<Ref> _call() { checkState(remote != null, "remote not provided"); checkState(toRemote != null, "must indicate whether to convert refs to local or remotes namespace"); Function<Ref, Ref> function = (r) -> toRemote.booleanValue() ? toRemote(r) : toLocal(r); return Lists.newArrayList(Iterables.transform(refs, function)); }
.setRemote(remote.getInfo())// .convertToRemote()// .addAll(remoteRefs)// .call(); .setRemote(remote.getInfo())// .convertToLocal()// .addAll(remoteLocalRefs)// .call();
public MapRef addAll(Iterable<Ref> refs) { for (Ref ref : refs) { add(ref); } return this; }
private Ref toLocal(Ref remoteRef) { Optional<String> localName = remote.mapToRemote(remoteRef.getName()); Preconditions.checkArgument(localName.isPresent(), "Can't map %s to local ref using %s", remoteRef.getName(), remote.getFetchSpec()); Ref localRef; if (remoteRef instanceof SymRef) { Ref target = toLocal(remoteRef.peel()); localRef = new SymRef(localName.get(), target); } else { localRef = new Ref(localName.get(), remoteRef.getObjectId()); } return localRef; }
private Ref toRemote(Ref localRef) { Optional<String> remoteName = remote.mapToLocal(localRef.getName()); Preconditions.checkArgument(remoteName.isPresent(), "Can't map %s to remote ref using %s", localRef.getName(), remote.getFetchSpec()); Ref remoteRef; if (localRef instanceof SymRef) { Ref target = toRemote(localRef.peel()); remoteRef = new SymRef(remoteName.get(), target); } else { remoteRef = new Ref(remoteName.get(), localRef.getObjectId()); } return remoteRef; }
.setRemote(remote)// .addAll(remoteRefs)// .convertToLocal()// .call();
private Ref toRemote(Remote remote, Ref local) { return localRepo.command(MapRef.class).setRemote(remote).add(local).convertToRemote().call() .get(0); }
.setRemote(remoteRepo.getInfo())// .add(remoteRef.get())// .convertToRemote().call().get(0); local.command(UpdateRef.class)//