@Test public void testPullRebase() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.setRebase(true).setAll(true).call(); Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call(); List<RevCommit> logged = new ArrayList<RevCommit>(); for (; logs.hasNext();) { logged.add(logs.next()); } assertEquals(expectedMaster, logged); }
@Test public void testPullTooManyRefs() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch:newbranch2"); exception.expect(IllegalArgumentException.class); pull.setRebase(true).call(); }
@Test public void testPullTooManyRefs() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch:newbranch2"); exception.expect(IllegalArgumentException.class); pull.setRebase(true).call(); }
@Test public void testPullRefspecForce() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("+master:newbranch"); pull.setRebase(true).call(); final Optional<Ref> currHead = localGeogig.geogig.command(RefParse.class).setName(Ref.HEAD) .call(); assertTrue(currHead.isPresent()); assertTrue(currHead.get() instanceof SymRef); final SymRef headRef = (SymRef) currHead.get(); final String currentBranch = Ref.localName(headRef.getTarget()); assertEquals("newbranch", currentBranch); Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call(); List<RevCommit> logged = new ArrayList<RevCommit>(); for (; logs.hasNext();) { logged.add(logs.next()); } assertEquals(expectedMaster, logged); }
@Test public void testPullRefspecs() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch"); pull.setRebase(true).call(); final Optional<Ref> currHead = localGeogig.geogig.command(RefParse.class).setName(Ref.HEAD) .call(); assertTrue(currHead.isPresent()); assertTrue(currHead.get() instanceof SymRef); final SymRef headRef = (SymRef) currHead.get(); final String currentBranch = Ref.localName(headRef.getTarget()); assertEquals("newbranch", currentBranch); Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call(); List<RevCommit> logged = new ArrayList<RevCommit>(); for (; logs.hasNext();) { logged.add(logs.next()); } assertEquals(expectedMaster, logged); }
@Test public void testPullRebase() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.setRebase(true).setAll(true).call(); List<RevCommit> logged = log(localGeogig.repo); assertEquals(expectedMaster, logged); }
@Test public void testPullRefspecs() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); checkout(localGeogig.repo, "Branch1"); List<RevCommit> logged = log(localGeogig.repo); assertEquals(3, logged.size()); assertFalse(getRef(localGeogig.repo, "refs/remotes/origin/newbranch").isPresent()); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/Branch1").isPresent()); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch"); pull.addRefSpec("Branch1"); PullResult result = pull.setRebase(true).call(); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/newbranch").isPresent()); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/Branch1").isPresent()); logged = log(localGeogig.repo); assertEquals(8, logged.size()); }
pull.addRefSpec("master:newbranch"); pull.addRefSpec("Branch1:newbranch2"); pull.setRebase(true).call();
@Test public void testPullNullCurrentBranch() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); localGeogig.geogig.command(UpdateRef.class).setName("master").setNewValue(ObjectId.NULL) .call(); localGeogig.geogig.command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue("master") .call(); // Pull the commit PullOp pull = pullOp(); pull.setRebase(true).call(); Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call(); List<RevCommit> logged = new ArrayList<RevCommit>(); for (; logs.hasNext();) { logged.add(logs.next()); } assertEquals(expectedMaster, logged); }
@Test public void testPullToCurrentBranch() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Make sure the local master matches the remote localGeogig.geogig.command(BranchCreateOp.class).setName("mynewbranch") .setAutoCheckout(true).call(); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master"); pull.setRebase(true).call(); final Optional<Ref> currHead = localGeogig.geogig.command(RefParse.class).setName(Ref.HEAD) .call(); assertTrue(currHead.isPresent()); assertTrue(currHead.get() instanceof SymRef); final SymRef headRef = (SymRef) currHead.get(); final String currentBranch = Ref.localName(headRef.getTarget()); assertEquals("mynewbranch", currentBranch); Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call(); List<RevCommit> logged = new ArrayList<RevCommit>(); for (; logs.hasNext();) { logged.add(logs.next()); } assertEquals(expectedMaster, logged); }
@Test public void testPullMultipleRefspecs() throws Exception { // Add a commit to the remote checkout(remoteGeogig.repo, "master"); insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); Feature points4 = feature(pointsType, "Points.4", "4", new Integer(4), "POINT(4 4)"); checkout(remoteGeogig.repo, "Branch1"); insertAndAdd(remoteGeogig.repo, points4); commit(remoteGeogig.repo, "Points.4"); assertFalse(getRef(localGeogig.repo, "refs/remotes/origin/newbranch").isPresent()); assertFalse(getRef(localGeogig.repo, "refs/remotes/origin/newbranch2").isPresent()); checkout(localGeogig.repo, "Branch1"); List<RevCommit> logged = log(localGeogig.repo); assertEquals(3, logged.size()); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch"); pull.addRefSpec("Branch1:newbranch2"); pull.setRebase(true).call(); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/newbranch").isPresent()); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/newbranch2").isPresent()); logged = log(localGeogig.repo); assertEquals(9, logged.size()); }
pull.setAll(all).setRebase(rebase).setFullDepth(fulldepth); pull.setDepth(depth);
pull.setAll(all).setRebase(rebase).setFullDepth(fulldepth); pull.setDepth(depth); pull.setIncludeIndexes(withIndexes);
pull.setAll(all).setRebase(rebase).setFullDepth(fulldepth); pull.setDepth(depth); pull.setIncludeIndexes(withIndexes);
@Test public void testPullToCurrentBranch() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Make sure the local master matches the remote localGeogig.geogig.command(BranchCreateOp.class).setName("mynewbranch") .setAutoCheckout(true).call(); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master"); pull.setRebase(true).call(); final Optional<Ref> currHead = localGeogig.geogig.command(RefParse.class).setName(Ref.HEAD) .call(); assertTrue(currHead.isPresent()); assertTrue(currHead.get() instanceof SymRef); final SymRef headRef = (SymRef) currHead.get(); final String currentBranch = Ref.localName(headRef.getTarget()); assertEquals("mynewbranch", currentBranch); List<RevCommit> logged = log(localGeogig.repo); assertEquals(expectedMaster, logged); }
@Test public void testPullRefspecForce() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); // fetch remote's master onto new ref refs/remotes/origin/newbranch, then pull from there pull.addRefSpec("+master:newbranch"); PullResult result = pull.setRebase(true).call(); Optional<Ref> fetchedToRef = getRef(localGeogig.repo, "refs/remotes/origin/newbranch"); assertTrue(fetchedToRef.isPresent()); List<RevCommit> logged = log(localGeogig.repo); assertEquals(expectedMaster, logged); Ref oldRef = result.getOldRef(); Ref newRef = result.getNewRef(); assertEquals("refs/heads/master", oldRef.getName()); assertEquals("refs/heads/master", newRef.getName()); assertEquals(fetchedToRef.get().getObjectId(), newRef.getObjectId()); }
@Test public void testPullNullCurrentBranch() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); localGeogig.geogig.command(UpdateRef.class).setName("master").setNewValue(ObjectId.NULL) .call(); localGeogig.geogig.command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue("master") .call(); // Pull the commit PullOp pull = pullOp(); pull.setRebase(true).call(); List<RevCommit> logged = log(localGeogig.repo); assertEquals(expectedMaster, logged); }