@Test public void NoBranchNameTest() { BranchDeleteOp testOp = new BranchDeleteOp(); testOp.setName(null); exception.expect(IllegalStateException.class); testOp.call(); }
protected Optional<? extends Ref> _call() { checkState(branchName != null, "Branch name not provided"); Optional<Ref> branchRef = command(RefParse.class).setName(branchName).call(); if (branchRef.isPresent()) { final Ref ref = branchRef.get(); checkState(!(ref instanceof SymRef)); final Optional<Ref> head = command(RefParse.class).setName(Ref.HEAD).call(); checkArgument( !(head.isPresent() && head.get() instanceof SymRef "Cannot delete the branch you are on"); UpdateRef updateRef = command(UpdateRef.class).setName(ref.getName()).setDelete(true) .setReason("Delete branch " + ref.getName()); branchRef = updateRef.call();
@Test public void NoBranchNameTest() { BranchDeleteOp testOp = new BranchDeleteOp(); testOp.setName(null); exception.expect(IllegalStateException.class); testOp.call(); }
protected Optional<? extends Ref> _call() { checkState(branchName != null, "Branch name not provided"); Optional<Ref> branchRef = command(RefParse.class).setName(branchName).call(); if (branchRef.isPresent()) { final Ref ref = branchRef.get(); checkState(!(ref instanceof SymRef)); final Optional<Ref> head = command(RefParse.class).setName(Ref.HEAD).call(); checkArgument( !(head.isPresent() && head.get() instanceof SymRef config = command(BranchConfigOp.class).setName(ref.getName()).delete(); } catch (RuntimeException ignore) { config = null; UpdateRef updateRef = command(UpdateRef.class).setName(ref.getName()).setDelete(true) .setReason("Delete branch " + ref.getName()); branchRef = updateRef.call();
@Test public void BranchPresentTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("TestBranch").call(); geogig.command(BranchDeleteOp.class).setName("TestBranch").call(); Optional<Ref> result = geogig.command(RefParse.class).setName("TestBranch").call(); assertFalse(result.isPresent()); }
@Test public void BranchPresentTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("TestBranch").call(); geogig.command(BranchDeleteOp.class).setName("TestBranch").call(); Optional<Ref> result = geogig.command(RefParse.class).setName("TestBranch").call(); assertFalse(result.isPresent()); }
@Test public void testFetchWithPrune() throws Exception { // fetch from the remote FetchOp fetch = fetchOp(); fetch.addRemote("origin").setAllRemotes(true).call(); verifyFetch(); Optional<Ref> localOriginBranch1 = getRef(localRepo, "refs/remotes/origin/Branch1"); assertTrue(localOriginBranch1.isPresent()); // Remove a branch from the remote remoteGeogig.geogig.command(BranchDeleteOp.class).setName("Branch1").call(); // fetch again fetch = fetchOp(); TransferSummary summary = fetch.setPrune(true).call(); assertSummary(summary, origin.getFetchURL(), localOriginBranch1, absent()); verifyPrune(); }
@Test public void testFetchWithPrune() throws Exception { // fetch from the remote FetchOp fetch = fetchOp(); fetch.addRemote("origin").setAll(true).call(); verifyFetch(); Optional<Ref> localOriginBranch1 = getRef(localRepo, "refs/remotes/origin/Branch1"); assertTrue(localOriginBranch1.isPresent()); // Remove a branch from the remote remoteGeogig.geogig.command(BranchDeleteOp.class).setName("Branch1").call(); // fetch again fetch = fetchOp(); TransferSummary summary = fetch.setPrune(true).call(); assertSummary(summary, origin.getFetchURL(), localOriginBranch1, absent()); verifyPrune(); }
@Test public void InvalidBranchNameTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); Ref testBranch = geogig.command(BranchCreateOp.class).setName("TestBranch").call(); testBranch = geogig.command(UpdateRef.class).setName("TestBranch") .setNewValue(testBranch.getObjectId()).call().get(); exception.expect(IllegalArgumentException.class); geogig.command(BranchDeleteOp.class).setName("TestBranch").call(); }
@Test public void InvalidBranchNameTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); Ref testBranch = geogig.command(BranchCreateOp.class).setName("TestBranch").call(); testBranch = geogig.command(UpdateRef.class).setName("TestBranch") .setNewValue(testBranch.getObjectId()).call().get(); exception.expect(IllegalArgumentException.class); geogig.command(BranchDeleteOp.class).setName("TestBranch").call(); } }
assertEquals("master", checkout(tx1, "master").getNewRef().localName()); Optional<? extends Ref> b1deleted = tx1.command(BranchDeleteOp.class).setName("branch1") .call(); assertTrue(b1deleted.isPresent()); assertTrue(refParse(tx2, "branch2").isPresent()); Optional<? extends Ref> b2deleted = tx2.command(BranchDeleteOp.class).setName("branch2") .call(); assertTrue(b2deleted.isPresent());