@Test public void SameNameTest() { exception.expect(IllegalArgumentException.class); geogig.command(BranchRenameOp.class).setNewName("master").setOldName("master").call(); }
geogig.command(BranchRenameOp.class).setNewName(branchName.get(0)).setForce(force) .call(); if (headRef.isPresent()) { SymRef ref = (SymRef) headRef.get(); geogig.command(BranchRenameOp.class).setOldName(branchName.get(0)) .setNewName(branchName.get(1)).setForce(force).call(); console.println("renamed branch '" + branchName.get(0) + "' to '" + branchName.get(1) + "'");
checkArgument(newBranchName != null, "New branch name not specified"); checkArgument(!newBranchName.equals(oldBranchName), "Done"); command(CheckRefFormat.class).setThrowsException(true).setRef(newBranchName) .setAllowOneLevel(true).call(); Optional<Ref> branch = Optional.absent(); Optional<Ref> headRef = command(RefParse.class).setName(Ref.HEAD).call(); checkArgument(headRef.isPresent() && headRef.get() instanceof SymRef, "Cannot rename detached HEAD."); branch = command(RefParse.class).setName(((SymRef) (headRef.get())).getTarget()).call(); } else { branch = command(RefParse.class).setName(oldBranchName).call(); Optional<Ref> newBranch = command(RefParse.class).setName(newBranchName).call(); Optional<Ref> renamedBranch = command(UpdateRef.class) .setName(branch.get().namespace() + newBranchName) .setNewValue(branch.get().getObjectId()).call(); List<Ref> symRefs = Lists.newArrayList(command(ForEachRef.class).setFilter(filter).call()); for (Ref ref : symRefs) { if (((SymRef) ref).getTarget().equals(branch.get().getName())) { command(UpdateSymRef.class).setName(ref.getName()) .setNewValue(renamedBranch.get().getName()).call(); command(UpdateRef.class).setName(branch.get().getName()).setDelete(true).call();
@Test public void InvalidBranchNameTest() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Component of ref cannot have two consecutive dots (..) anywhere."); geogig.command(BranchRenameOp.class).setNewName("ma..er").call(); }
Ref SuperTestBranch = geogig.command(BranchRenameOp.class).setNewName("TestBranch2") .setForce(true).call(); geogig.command(BranchRenameOp.class).setNewName("master").call();
@Test public void NoBranchNameTest() { exception.expect(IllegalArgumentException.class); geogig.command(BranchRenameOp.class).call(); }
Ref SuperTestBranch = geogig.command(BranchRenameOp.class).setNewName("TestBranch2") .setForce(true).call(); geogig.command(BranchRenameOp.class).setNewName("master").call();
@Test public void InvalidBranchNameTest() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Component of ref cannot have two consecutive dots (..) anywhere."); geogig.command(BranchRenameOp.class).setNewName("ma..er").call(); }
@Test public void NoBranchNameTest() { exception.expect(IllegalArgumentException.class); geogig.command(BranchRenameOp.class).call(); }
@Test public void SameNameTest() { exception.expect(IllegalArgumentException.class); geogig.command(BranchRenameOp.class).setNewName("master").setOldName("master").call(); }
geogig.command(BranchRenameOp.class).setNewName(branchName.get(0)).setForce(force) .call(); if (headRef.isPresent()) { SymRef ref = (SymRef) headRef.get(); geogig.command(BranchRenameOp.class).setOldName(branchName.get(0)) .setNewName(branchName.get(1)).setForce(force).call(); console.println("renamed branch '" + branchName.get(0) + "' to '" + branchName.get(1) + "'");
@Test public void NoOldNameTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); Ref TestBranch = geogig.command(BranchCreateOp.class).setName("TestBranch") .setAutoCheckout(true).call(); Ref SuperTestBranch = geogig.command(BranchRenameOp.class).setNewName("SuperTestBranch") .call(); Optional<Ref> result = geogig.command(RefParse.class).setName("TestBranch").call(); assertFalse(result.isPresent()); result = geogig.command(RefParse.class).setName("SuperTestBranch").call(); assertTrue(result.isPresent()); assertEquals(TestBranch.getObjectId(), SuperTestBranch.getObjectId()); }
checkArgument(newBranchName != null, "New branch name not specified"); checkArgument(!newBranchName.equals(oldBranchName), "Done"); command(CheckRefFormat.class).setThrowsException(true).setRef(newBranchName) .setAllowOneLevel(true).call(); Optional<Ref> oldBranch = Optional.absent(); Optional<Ref> headRef = command(RefParse.class).setName(Ref.HEAD).call(); checkArgument(headRef.isPresent() && headRef.get() instanceof SymRef, "Cannot rename detached HEAD."); oldBranch = command(RefParse.class).setName(headRef.get().peel().localName()).call(); } else { oldBranch = command(RefParse.class).setName(oldBranchName).call(); Optional<Ref> newBranch = command(RefParse.class).setName(newBranchName).call(); Optional<Ref> renamedBranch = command(UpdateRef.class) .setName(oldBranch.get().namespace() + newBranchName) .setNewValue(oldBranch.get().getObjectId()).call(); final BranchConfig oldConfig = command(BranchConfigOp.class) .setName(oldBranch.get().localName()).delete(); final BranchConfig newConfig = command(BranchConfigOp.class) List<Ref> symRefs = Lists.newArrayList(command(ForEachRef.class).setFilter(filter).call()); for (Ref ref : symRefs) { if (((SymRef) ref).getTarget().equals(oldBranch.get().getName())) { command(UpdateSymRef.class).setName(ref.getName()) .setNewValue(renamedBranch.get().getName()).call();
@Test public void RenamingCurrentBranchTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); Ref NewMaster = geogig.command(BranchRenameOp.class).setOldName("master") .setNewName("newMaster").call(); assertEquals(Ref.HEADS_PREFIX + "newMaster", NewMaster.getName()); Optional<Ref> result = geogig.command(RefParse.class).setName("master").call(); assertFalse(result.isPresent()); result = geogig.command(RefParse.class).setName("newMaster").call(); assertTrue(result.isPresent()); result = geogig.command(RefParse.class).setName(Ref.HEAD).call(); assertTrue(result.isPresent()); assertTrue(result.get() instanceof SymRef); assertEquals(NewMaster.getName(), ((SymRef) result.get()).getTarget()); }
geogig.command(BranchRenameOp.class).setNewName(branchName.get(0)).setForce(force) .call(); if (headRef.isPresent()) { SymRef ref = (SymRef) headRef.get(); geogig.command(BranchRenameOp.class).setOldName(branchName.get(0)) .setNewName(branchName.get(1)).setForce(force).call(); console.println("renamed branch '" + branchName.get(0) + "' to '" + branchName.get(1) + "'");
@Test public void NoOldNameTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); Ref TestBranch = geogig.command(BranchCreateOp.class).setName("TestBranch") .setAutoCheckout(true).call(); Ref SuperTestBranch = geogig.command(BranchRenameOp.class).setNewName("SuperTestBranch") .call(); Optional<Ref> result = geogig.command(RefParse.class).setName("TestBranch").call(); assertFalse(result.isPresent()); result = geogig.command(RefParse.class).setName("SuperTestBranch").call(); assertTrue(result.isPresent()); assertEquals(TestBranch.getObjectId(), SuperTestBranch.getObjectId()); }
@Test public void RenamingABranchTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); Ref TestBranch = geogig.command(BranchCreateOp.class).setName("TestBranch").call(); Ref SuperTestBranch = geogig.command(BranchRenameOp.class).setOldName("TestBranch") .setNewName("SuperTestBranch").call(); Optional<Ref> result = geogig.command(RefParse.class).setName("TestBranch").call(); assertFalse(result.isPresent()); result = geogig.command(RefParse.class).setName("SuperTestBranch").call(); assertTrue(result.isPresent()); assertEquals(TestBranch.getObjectId(), SuperTestBranch.getObjectId()); }
@Test public void RenamingCurrentBranchTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); Ref NewMaster = geogig.command(BranchRenameOp.class).setOldName("master") .setNewName("newMaster").call(); assertEquals(Ref.HEADS_PREFIX + "newMaster", NewMaster.getName()); Optional<Ref> result = geogig.command(RefParse.class).setName("master").call(); assertFalse(result.isPresent()); result = geogig.command(RefParse.class).setName("newMaster").call(); assertTrue(result.isPresent()); result = geogig.command(RefParse.class).setName(Ref.HEAD).call(); assertTrue(result.isPresent()); assertTrue(result.get() instanceof SymRef); assertEquals(NewMaster.getName(), ((SymRef) result.get()).getTarget()); }
@Test public void RenamingABranchTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); Ref TestBranch = geogig.command(BranchCreateOp.class).setName("TestBranch").call(); Ref SuperTestBranch = geogig.command(BranchRenameOp.class).setOldName("TestBranch") .setNewName("SuperTestBranch").call(); Optional<Ref> result = geogig.command(RefParse.class).setName("TestBranch").call(); assertFalse(result.isPresent()); result = geogig.command(RefParse.class).setName("SuperTestBranch").call(); assertTrue(result.isPresent()); assertEquals(TestBranch.getObjectId(), SuperTestBranch.getObjectId()); }
@Test public void RenamingUpdatesSymRefsTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); Ref TestBranch = geogig.command(BranchCreateOp.class).setName("TestBranch").call(); Optional<Ref> TestSymRef = geogig.command(UpdateSymRef.class) .setName(Ref.HEADS_PREFIX + "TestSymRef").setNewValue(TestBranch.getName()).call(); assertTrue(TestSymRef.isPresent()); assertEquals(TestBranch.getName(), ((SymRef) TestSymRef.get()).getTarget()); Ref SuperTestBranch = geogig.command(BranchRenameOp.class).setOldName("TestBranch") .setNewName("SuperTestBranch").call(); Optional<Ref> result = geogig.command(RefParse.class).setName("TestBranch").call(); assertFalse(result.isPresent()); result = geogig.command(RefParse.class).setName("SuperTestBranch").call(); assertTrue(result.isPresent()); result = geogig.command(RefParse.class).setName("TestSymRef").call(); assertTrue(result.isPresent()); assertTrue(result.get() instanceof SymRef); assertEquals(SuperTestBranch.getName(), ((SymRef) result.get()).getTarget()); }