/** * Delete the given refspec from the remote repository. * * @param refspec the refspec to delete */ @Override public Optional<Ref> deleteRef(String refspec) { Optional<Ref> deletedRef = remoteRepository.command(UpdateRef.class).setName(refspec) .setDelete(true).call(); return deletedRef; }
/** * Delete the given refspec from the remote repository. * * @param refspec the refspec to delete */ @Override public Optional<Ref> deleteRef(String refspec) { Optional<Ref> deletedRef = remoteRepo.command(UpdateRef.class).setName(refspec) .setDelete(true).call(); return deletedRef; }
/** * Delete the given refspec from the remote repository. * * @param refspec the refspec to delete */ @Override public Optional<Ref> deleteRef(String refspec) { Optional<Ref> deletedRef = remoteRepository.command(UpdateRef.class).setName(refspec) .setDelete(true).call(); return deletedRef; }
@Override protected ImmutableList<String> _call() { Builder<String> cleaned = new ImmutableList.Builder<String>(); Optional<Ref> ref = command(UpdateRef.class).setDelete(true).setName(Ref.MERGE_HEAD).call(); if (ref.isPresent()) { cleaned.add(Ref.MERGE_HEAD); } ref = command(UpdateRef.class).setDelete(true).setName(Ref.ORIG_HEAD).call(); if (ref.isPresent()) { cleaned.add(Ref.ORIG_HEAD); } ref = command(UpdateRef.class).setDelete(true).setName(Ref.CHERRY_PICK_HEAD).call(); if (ref.isPresent()) { cleaned.add(Ref.CHERRY_PICK_HEAD); } BlobStore blobStore = context.blobStore(); Optional<byte[]> blob = Blobs.getBlob(blobStore, MergeOp.MERGE_MSG); if (blob.isPresent()) { cleaned.add(MergeOp.MERGE_MSG); blobStore.removeBlob(MergeOp.MERGE_MSG); } return cleaned.build(); }
/** * Delete the given refspec from the remote repository. * * @param refspec the refspec to delete */ @Override public Optional<Ref> deleteRef(String refspec) { Optional<Ref> deletedRef = remoteRepo.command(UpdateRef.class).setName(refspec) .setDelete(true).call(); return deletedRef; }
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 delete(Context liveContext, String ref) { liveContext.command(UpdateRef.class).setName(ref).setDelete(true).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(); } } }
/** * Executes the tag removal operation. * * @return the tag to remove * */ @Override protected RevTag _call() throws RuntimeException { String fullPath = Ref.TAGS_PREFIX + name; Optional<RevObject> revTag = command(RevObjectParse.class).setRefSpec(fullPath).call(); Preconditions.checkArgument(revTag.isPresent(), "Wrong tag name: " + name); Preconditions.checkArgument(revTag.get().getType().equals(RevObject.TYPE.TAG), name + " does not resolve to a tag"); UpdateRef updateRef = command(UpdateRef.class).setName(fullPath).setDelete(true) .setReason("Delete tag " + name); Optional<Ref> tagRef = updateRef.call(); checkState(tagRef.isPresent()); return (RevTag) revTag.get(); }
/** * Executes the tag removal operation. * * @return the tag to remove * */ @Override protected RevTag _call() throws RuntimeException { String fullPath = Ref.TAGS_PREFIX + name; Optional<RevObject> revTag = command(RevObjectParse.class).setRefSpec(fullPath).call(); Preconditions.checkArgument(revTag.isPresent(), "Wrong tag name: " + name); Preconditions.checkArgument(revTag.get().getType().equals(RevObject.TYPE.TAG), name + " does not resolve to a tag"); UpdateRef updateRef = command(UpdateRef.class).setName(fullPath).setDelete(true) .setReason("Delete tag " + name); Optional<Ref> tagRef = updateRef.call(); checkState(tagRef.isPresent()); return (RevTag) revTag.get(); }
@Override protected ImmutableList<String> _call() { Builder<String> cleaned = new ImmutableList.Builder<String>(); Optional<Ref> ref = command(RefParse.class).setName(Ref.MERGE_HEAD).call(); if (ref.isPresent()) { cleaned.add(Ref.MERGE_HEAD); command(UpdateRef.class).setDelete(true).setName(Ref.MERGE_HEAD).call(); } ref = command(RefParse.class).setName(Ref.ORIG_HEAD).call(); if (ref.isPresent()) { cleaned.add(Ref.ORIG_HEAD); command(UpdateRef.class).setDelete(true).setName(Ref.ORIG_HEAD).call(); } ref = command(RefParse.class).setName(Ref.CHERRY_PICK_HEAD).call(); if (ref.isPresent()) { cleaned.add(Ref.CHERRY_PICK_HEAD); command(UpdateRef.class).setDelete(true).setName(Ref.CHERRY_PICK_HEAD).call(); } BlobStore blobStore = context.blobStore(); Optional<String> blob = Blobs.getBlobAsString(blobStore, MergeOp.MERGE_MSG); if (blob.isPresent()) { cleaned.add(MergeOp.MERGE_MSG); blobStore.removeBlob(MergeOp.MERGE_MSG); } return cleaned.build(); }
protected @Override Void _call() { getProgressListener().started(); Optional<Ref> origHead = command(RefParse.class).setName(Ref.ORIG_HEAD).call(); Preconditions.checkState(origHead.isPresent(), "Cannot abort. You are not in the middle of a revert process."); // Revert can only be run in a conflicted situation if the abort option is used final boolean hasConflicts = conflictsDatabase().hasConflicts(null); if (hasConflicts) { log.debug("Aborting revert op, will reset conflicts too"); } final ObjectId commitId = origHead.get().getObjectId(); command(ResetOp.class).setMode(ResetMode.HARD).setCommit(commitId).call(); command(UpdateRef.class).setDelete(true).setName(Ref.ORIG_HEAD).call(); getProgressListener().complete(); return null; } }
@Test public void testDeleteWithNonexistentName() { Optional<Ref> ref = geogig.command(UpdateRef.class).setDelete(true).setName("NoRef").call(); assertFalse(ref.isPresent()); } }
@Test public void testDeleteWithNonexistentName() { Optional<Ref> ref = geogig.command(UpdateRef.class).setDelete(true).setName("NoRef").call(); assertFalse(ref.isPresent()); } }
/** * Updates the remote ref that matches the given refspec. * * @param refspec the ref to update * @param commitId the new value of the ref * @param delete if true, the remote ref will be deleted * @return the updated ref */ @Override protected Optional<Ref> updateRemoteRef(String refspec, ObjectId commitId, boolean delete) { Optional<Ref> updatedRef = remoteRepo.command(UpdateRef.class).setName(refspec) .setNewValue(commitId).setDelete(delete).call(); if (updatedRef.isPresent()) { final Ref remoteHead = headRef().orNull(); if (remoteHead instanceof SymRef) { if (((SymRef) remoteHead).getTarget().equals(updatedRef.get().getName())) { remoteRepo.command(UpdateSymRef.class).setName(Ref.HEAD) .setNewValue(updatedRef.get().getName()).call(); RevCommit commit = remoteRepo.getCommit(commitId); remoteRepo.workingTree().updateWorkHead(commit.getTreeId()); remoteRepo.index().updateStageHead(commit.getTreeId()); } } } return updatedRef; }
/** * Updates the remote ref that matches the given refspec. * * @param refspec the ref to update * @param commitId the new value of the ref * @param delete if true, the remote ref will be deleted * @return the updated ref */ @Override protected Optional<Ref> updateRemoteRef(String refspec, ObjectId commitId, boolean delete) { Optional<Ref> updatedRef = remoteRepo.command(UpdateRef.class).setName(refspec) .setNewValue(commitId).setDelete(delete).call(); if (updatedRef.isPresent()) { final Ref remoteHead = headRef().orNull(); if (remoteHead instanceof SymRef) { if (((SymRef) remoteHead).getTarget().equals(updatedRef.get().getName())) { remoteRepo.command(UpdateSymRef.class).setName(Ref.HEAD) .setNewValue(updatedRef.get().getName()).call(); RevCommit commit = remoteRepo.getCommit(commitId); remoteRepo.workingTree().updateWorkHead(commit.getTreeId()); remoteRepo.index().updateStageHead(commit.getTreeId()); } } } return updatedRef; }
private Iterable<RefDiff> updateLocalRemoteRefs(Remote remote, List<LocalRemoteRef> fetchSpecs, final boolean prune) { List<RefDiff> updatedLocalRemoteRefs = new ArrayList<>(); for (LocalRemoteRef expected : fetchSpecs) { final boolean isNew = expected.isNew; final boolean remoteDeleted = expected.remoteDeleted; final String localName = expected.localRemoteRef.getName(); if (remoteDeleted) { if (prune) { updatedLocalRemoteRefs.add(RefDiff.removed(expected.localRemoteRef)); command(UpdateRef.class).setName(localName) .setOldValue(expected.localRemoteRef.getObjectId()).setDelete(true) .call(); } continue; } RefDiff localRefDiff; Ref oldRef = isNew ? null : expected.localRemoteRef; Ref newRef = new Ref(localName, expected.remoteRef.getObjectId()); command(UpdateRef.class).setName(localName).setNewValue(newRef.getObjectId()).call(); localRefDiff = new RefDiff(oldRef, newRef); updatedLocalRemoteRefs.add(localRefDiff); } return updatedLocalRemoteRefs; }
UpdateRef cmd = command(UpdateRef.class)// .setDelete(delete); if (!delete) {
@Test public void testDeleteRefThatWasASymRef() throws Exception { insertAndAdd(points1); RevCommit commit1 = geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("branch1").call(); insertAndAdd(points2); RevCommit commit2 = geogig.command(CommitOp.class).call(); geogig.command(UpdateSymRef.class).setName("refs/heads/branch1") .setOldValue(commit1.getId().toString()).setNewValue(Ref.MASTER) .setReason("this is a test").call(); geogig.command(UpdateRef.class).setName("refs/heads/branch1").setNewValue(commit2.getId()) .setOldValue(Ref.MASTER).call(); Optional<Ref> branchId = geogig.command(RefParse.class).setName("refs/heads/branch1") .call(); assertTrue(branchId.get().getObjectId().equals(commit2.getId())); geogig.command(UpdateRef.class).setDelete(true).setName("refs/heads/branch1").call(); }
@Test public void testDeleteRefThatWasASymRef() throws Exception { insertAndAdd(points1); RevCommit commit1 = geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("branch1").call(); insertAndAdd(points2); RevCommit commit2 = geogig.command(CommitOp.class).call(); geogig.command(UpdateSymRef.class).setName("refs/heads/branch1") .setOldValue(commit1.getId().toString()).setNewValue(Ref.MASTER) .setReason("this is a test").call(); geogig.command(UpdateRef.class).setName("refs/heads/branch1").setNewValue(commit2.getId()) .setOldValue(Ref.MASTER).call(); Optional<Ref> branchId = geogig.command(RefParse.class).setName("refs/heads/branch1") .call(); assertTrue(branchId.get().getObjectId().equals(commit2.getId())); geogig.command(UpdateRef.class).setDelete(true).setName("refs/heads/branch1").call(); }