/** * @param remoteName the name or URL of a remote repository to fetch from * @return {@code this} */ public FetchOp addRemote(final String remoteName) { checkNotNull(remoteName); return addRemote(command(RemoteResolve.class).setName(remoteName)); }
private ImmutableSet<Ref> getRemoteLocalRefs(Remote remote) { final ImmutableSet<Ref> localRemoteRefs; localRemoteRefs = command(LsRemoteOp.class)// .retrieveLocalRefs(true)// .setRemote(Suppliers.ofInstance(Optional.of(remote)))// .call(); return localRemoteRefs; }
/** * @param remoteName the name or URL of a remote repository to fetch from * @return {@code this} */ public FetchOp addRemote(final String remoteName) { checkNotNull(remoteName); return addRemote(command(RemoteResolve.class).setName(remoteName)); }
private ImmutableSet<Ref> getRemoteLocalRefs(Remote remote) { final ImmutableSet<Ref> localRemoteRefs; localRemoteRefs = command(LsRemoteOp.class)// .retrieveLocalRefs(true)// .setRemote(Suppliers.ofInstance(Optional.of(remote)))// .call(); return localRemoteRefs; }
private void prune(final ImmutableSet<Ref> remoteRemoteRefs, final ImmutableSet<Ref> localRemoteRefs, List<RefDiff> needUpdate) { // Delete local refs that aren't in the remote List<Ref> locals = new ArrayList<Ref>(); // only branches, not tags, appear in the remoteRemoteRefs list so we will not catch // any tags in this check. However, we do not track which remote originally // provided a tag so it makes sense not to prune them anyway. for (Ref remoteRef : remoteRemoteRefs) { Optional<Ref> localRef = findLocal(remoteRef, localRemoteRefs); if (localRef.isPresent()) { locals.add(localRef.get()); } } for (Ref localRef : localRemoteRefs) { if (!(localRef instanceof SymRef) && !locals.contains(localRef)) { // Delete the ref RefDiff RefDiff = new RefDiff(localRef, null); needUpdate.add(RefDiff); command(UpdateRef.class).setDelete(true).setName(localRef.getName()).call(); } } }
private void prune(final ImmutableSet<Ref> remoteRemoteRefs, final ImmutableSet<Ref> localRemoteRefs, List<RefDiff> needUpdate) { // Delete local refs that aren't in the remote List<Ref> locals = new ArrayList<Ref>(); // only branches, not tags, appear in the remoteRemoteRefs list so we will not catch // any tags in this check. However, we do not track which remote originally // provided a tag so it makes sense not to prune them anyway. for (Ref remoteRef : remoteRemoteRefs) { Optional<Ref> localRef = findLocal(remoteRef, localRemoteRefs); if (localRef.isPresent()) { locals.add(localRef.get()); } } for (Ref localRef : localRemoteRefs) { if (!(localRef instanceof SymRef) && !locals.contains(localRef)) { // Delete the ref RefDiff RefDiff = new RefDiff(localRef, null); needUpdate.add(RefDiff); command(UpdateRef.class).setDelete(true).setName(localRef.getName()).call(); } } }
private IRemoteRepo openRemote(Remote remote) { return command(OpenRemote.class).setRemote(remote).readOnly().call(); }
private IRemoteRepo openRemote(Remote remote) { return command(OpenRemote.class).setRemote(remote).readOnly().call(); }
/** * Finds the corresponding local reference in {@code localRemoteRefs} for the given remote ref * * @param remoteRef a ref in the {@code refs/heads} or {@code refs/tags} namespace as given by * {@link LsRemoteOp} when querying a remote repository * @param localRemoteRefs the list of locally known references of the given remote in the * {@code refs/remotes/<remote name>/} namespace */ private Optional<Ref> findLocal(Ref remoteRef, ImmutableSet<Ref> localRemoteRefs) { if (remoteRef.getName().startsWith(Ref.TAGS_PREFIX)) { return command(RefParse.class).setName(remoteRef.getName()).call(); } else { for (Ref localRef : localRemoteRefs) { if (localRef.localName().equals(remoteRef.localName())) { return Optional.of(localRef); } } return Optional.absent(); } } }
/** * Finds the corresponding local reference in {@code localRemoteRefs} for the given remote ref * * @param remoteRef a ref in the {@code refs/heads} or {@code refs/tags} namespace as given by * {@link LsRemoteOp} when querying a remote repository * @param localRemoteRefs the list of locally known references of the given remote in the * {@code refs/remotes/<remote name>/} namespace */ private Optional<Ref> findLocal(Ref remoteRef, ImmutableSet<Ref> localRemoteRefs) { if (remoteRef.getName().startsWith(Ref.TAGS_PREFIX)) { return command(RefParse.class).setName(remoteRef.getName()).call(); } else { for (Ref localRef : localRemoteRefs) { if (localRef.localName().equals(remoteRef.localName())) { return Optional.of(localRef); } } return Optional.absent(); } } }
private ImmutableSet<Ref> getRemoteRefs(final IRemoteRepo remoteRepo, final FetchArgs args, Remote remote) { final Optional<Integer> repoDepth = repository().getDepth(); final boolean getTags = args.fetchTags && !remote.getMapped() && (!repoDepth.isPresent() || args.fullDepth); ImmutableSet<Ref> remoteRemoteRefs; remoteRemoteRefs = command(LsRemoteOp.class)// .setRemote(remoteRepo)// .retrieveLocalRefs(false)// .retrieveTags(getTags)// .call(); return remoteRemoteRefs; }
private ImmutableSet<Ref> getRemoteRefs(final IRemoteRepo remoteRepo, final FetchArgs args, Remote remote) { final Optional<Integer> repoDepth = repository().getDepth(); final boolean getTags = args.fetchTags && !remote.getMapped() && (!repoDepth.isPresent() || args.fullDepth); ImmutableSet<Ref> remoteRemoteRefs; remoteRemoteRefs = command(LsRemoteOp.class)// .setRemote(remoteRepo)// .retrieveLocalRefs(false)// .retrieveTags(getTags)// .call(); return remoteRemoteRefs; }
private Ref updateLocalRef(Ref remoteRef, Remote remote, ImmutableSet<Ref> localRemoteRefs) { final String refName; if (remoteRef.getName().startsWith(Ref.TAGS_PREFIX)) { refName = remoteRef.getName(); } else { refName = Ref.REMOTES_PREFIX + remote.getName() + "/" + remoteRef.localName(); } Ref updatedRef = remoteRef; if (remoteRef instanceof SymRef) { String targetBranch = Ref.localName(((SymRef) remoteRef).getTarget()); String newTarget = Ref.REMOTES_PREFIX + remote.getName() + "/" + targetBranch; updatedRef = command(UpdateSymRef.class).setName(refName).setNewValue(newTarget).call() .get(); } else { ObjectId effectiveId = remoteRef.getObjectId(); if (remote.getMapped() && !repository().commitExists(remoteRef.getObjectId())) { effectiveId = graphDatabase().getMapping(effectiveId); } updatedRef = command(UpdateRef.class).setName(refName).setNewValue(effectiveId).call() .get(); } return updatedRef; }
private Ref updateLocalRef(Ref remoteRef, Remote remote, ImmutableSet<Ref> localRemoteRefs) { final String refName; if (remoteRef.getName().startsWith(Ref.TAGS_PREFIX)) { refName = remoteRef.getName(); } else { refName = Ref.REMOTES_PREFIX + remote.getName() + "/" + remoteRef.localName(); } Ref updatedRef = remoteRef; if (remoteRef instanceof SymRef) { String targetBranch = Ref.localName(((SymRef) remoteRef).getTarget()); String newTarget = Ref.REMOTES_PREFIX + remote.getName() + "/" + targetBranch; updatedRef = command(UpdateSymRef.class).setName(refName).setNewValue(newTarget).call() .get(); } else { ObjectId effectiveId = remoteRef.getObjectId(); if (remote.getMapped() && !repository().commitExists(remoteRef.getObjectId())) { effectiveId = graphDatabase().getMapping(effectiveId); } updatedRef = command(UpdateRef.class).setName(refName).setNewValue(effectiveId).call() .get(); } return updatedRef; }
command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET) .setScope(ConfigScope.LOCAL).setName(Repository.DEPTH_CONFIG_KEY) .setValue(Integer.toString(newDepth)).call();
command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET) .setScope(ConfigScope.LOCAL).setName(Repository.DEPTH_CONFIG_KEY) .setValue(Integer.toString(newDepth)).call();