@Test public void testCheckoutNoParametersSet() { exception.expect(IllegalStateException.class); geogig.command(CheckoutOp.class).call(); }
public TestData checkout(String branch) { getContext().command(CheckoutOp.class).setSource(branch).call(); Ref head = getContext().command(RefParse.class).setName(Ref.HEAD).call().get(); if (head instanceof SymRef) { String target = ((SymRef) head).getTarget(); head = getContext().command(RefParse.class).setName(target).call().get(); } String headBranch = head.localName(); checkState(branch.equals(headBranch), "expected %s, got %s", branch, headBranch); return this; }
@Test public void testCheckoutBranchDuringConflict() throws Exception { createConflictedState(); try { geogig.command(CheckoutOp.class).setSource("TestBranch").call(); } catch (CheckoutException e) { assertTrue(true); } }
public TestData checkout(String branch) { getContext().command(CheckoutOp.class).setSource(branch).call(); Ref head = getContext().command(RefParse.class).setName(Ref.HEAD).call().get(); if (head instanceof SymRef) { String target = ((SymRef) head).getTarget(); head = getContext().command(RefParse.class).setName(target).call().get(); } String headBranch = head.localName(); checkState(branch.equals(headBranch), "expected %s, got %s", branch, headBranch); return this; }
private void verifyPrune() throws Exception { // Make sure the local repository got all of the commits from master localGeogig.geogig.command(CheckoutOp.class).setForce(true) .setSource("refs/remotes/origin/master").call(); Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call(); List<RevCommit> logged = Lists.newArrayList(logs); assertEquals(expectedMaster, logged); // Make sure the local repository no longer has Branch1 Optional<Ref> missing = localGeogig.geogig.command(RefParse.class) .setName("refs/remotes/origin/Branch1").call(); assertFalse(missing.isPresent()); }
private void verifyPrune() throws Exception { // Make sure the local repository got all of the commits from master localGeogig.geogig.command(CheckoutOp.class).setForce(true) .setSource("refs/remotes/origin/master").call(); Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call(); List<RevCommit> logged = Lists.newArrayList(logs); assertEquals(expectedMaster, logged); // Make sure the local repository no longer has Branch1 Optional<Ref> missing = localGeogig.geogig.command(RefParse.class) .setName("refs/remotes/origin/Branch1").call(); assertFalse(missing.isPresent()); }
private void verifyPrune() throws Exception { // Make sure the local repository got all of the commits from master localGeogig.geogig.command(CheckoutOp.class).setForce(true) .setSource("refs/remotes/origin/master").call(); Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call(); List<RevCommit> logged = Lists.newArrayList(logs); assertEquals(expectedMaster, logged); // Make sure the local repository no longer has Branch1 Optional<Ref> missing = localGeogig.geogig.command(RefParse.class) .setName("refs/remotes/origin/Branch1").call(); assertFalse(missing.isPresent()); }
@Test public void testCheckoutPathFilterWithNothingInIndex() throws Exception { insertAndAdd(points2); insert(points1_modified); exception.expect(IllegalArgumentException.class); geogig.command(CheckoutOp.class).addPath("Points/Points.1").call(); }
@Test public void testCheckoutPathDuringConflict() throws Exception { createConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); try { geogig.command(CheckoutOp.class).addPath(path).call(); } catch (CheckoutException e) { assertTrue(true); } }
@Test public void testCheckoutOursAndBranchDuringConflict() throws Exception { createConflictedState(); try { geogig.command(CheckoutOp.class).setSource("TestBranch").setOurs(true).call(); } catch (IllegalArgumentException e) { assertTrue(true); } }
@Test public void testCheckoutPathFilterWithNothingInIndex() throws Exception { insertAndAdd(points2); insert(points1_modified); exception.expect(IllegalArgumentException.class); geogig.command(CheckoutOp.class).addPath("Points/Points.1").call(); }
@Test public void testCheckoutOursAndTheirs() throws Exception { try { geogig.command(CheckoutOp.class).setOurs(true).setTheirs(true).addPath("dummypath") .call(); fail(); } catch (IllegalArgumentException e) { assertTrue(true); } }
@Test public void testCheckoutTheirs() throws Exception { createConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).setTheirs(true).call(); Optional<Node> node = geogig.getRepository().workingTree().findUnstaged(path); String headPath = Ref.MERGE_HEAD + ":" + path; Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(headPath).call(); assertEquals(id.get(), node.get().getObjectId()); }
@Test public void testCheckoutOursDeleted() throws Exception { createDeleteOursConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).setOurs(true).call(); Optional<Node> node = geogig.getRepository().index().findStaged(path); assertFalse(node.isPresent()); String headPath = Ref.HEAD + ":" + path; Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(headPath).call(); assertFalse(id.isPresent()); }
@Test public void testCheckoutTheirsDeleted() throws Exception { createDeleteTheirsConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).setTheirs(true).call(); Optional<Node> node = geogig.getRepository().index().findStaged(path); assertFalse(node.isPresent()); String headPath = Ref.MERGE_HEAD + ":" + path; Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(headPath).call(); assertFalse(id.isPresent()); }
@Test public void testCheckoutOurs() throws Exception { createConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).setOurs(true).call(); Optional<Node> node = geogig.getRepository().workingTree().findUnstaged(path); String headPath = Ref.HEAD + ":" + path; Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(headPath).call(); assertEquals(id.get(), node.get().getObjectId()); }
@Test public void testCheckoutForceDuringConflict() throws Exception { createConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); String path2 = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).addPath(path2).setForce(true).call(); }
@Test public void testCheckoutPathFilter() throws Exception { ObjectId points1Id = insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("commit for " + idP1).call(); insert(points1_modified); CheckoutResult result = geogig.command(CheckoutOp.class).addPath("Points/Points.1").call(); Optional<RevTree> workTree = geogig.command(RevObjectParse.class) .setObjectId(result.getNewTree()).call(RevTree.class); Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(workTree.get()) .setChildPath("Points/Points.1").call(); assertEquals(points1Id, nodeRef.get().getNode().getObjectId()); }
@Test public void testCheckoutBranchWithChangesInTheIndex() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("commit for " + idP1).call(); geogig.command(BranchCreateOp.class).setName("branch1").call(); insertAndAdd(points2); exception.expect(CheckoutException.class); geogig.command(CheckoutOp.class).setSource("branch1").call(); }
@Test public void testCheckoutBranchWithChangesInTheWorkTree() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("commit for " + idP1).call(); geogig.command(BranchCreateOp.class).setName("branch1").call(); insert(points2); exception.expect(CheckoutException.class); geogig.command(CheckoutOp.class).setSource("branch1").call(); }