protected void createBranch(Repository repo, String branch) { repo.command(BranchCreateOp.class).setAutoCheckout(true).setName(branch) .setProgressListener(SIMPLE_PROGRESS).call(); }
@Test public void testCreateBranchWithTheSameNameAsExistingBranch() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true).call(); exception.expect(IllegalArgumentException.class); geogig.command(BranchCreateOp.class).setName("branch1").call(); }
if (isBranch) { Ref ref = command(BranchCreateOp.class)// .setName(refName)// .setForce(true)// .setSource(localRef.getObjectId().toString())// .setRemoteName(remote.getName())// .setRemoteBranch(refName)// .call(); createdBranches.add(ref.localName());
@Test public void testOrphan() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); Ref branch1 = geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true) .setOrphan(true).call(); assertEquals(ObjectId.NULL, branch1.getObjectId()); assertEquals(Ref.HEADS_PREFIX + "branch1", branch1.getName()); } }
@Test public void testCreateBranchWithTheSameNameAsExistingBranchAndForce() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); geogig.command(BranchCreateOp.class).setName("branch1").call(); insertAndAdd(points2); RevCommit newCommit = geogig.command(CommitOp.class).setMessage("Commit2").call(); geogig.command(BranchCreateOp.class).setName("branch1").setForce(true).call(); Optional<Ref> branch1 = geogig.command(RefParse.class).setName("branch1").call(); assertTrue(branch1.isPresent()); assertEquals(branch1.get().getObjectId(), newCommit.getId()); }
@Test public void testCreateSchemaOnBranch() throws IOException { final String branchName = "testBranch"; geogig.command(BranchCreateOp.class).setName(branchName).setOrphan(true).call(); dataStore.setHead(branchName); final SimpleFeatureType featureType = super.linesType; dataStore.createSchema(featureType); List<String> typeNames; typeNames = getTypeNames(Ref.HEAD); assertTrue(typeNames.isEmpty()); typeNames = getTypeNames(branchName); assertEquals(1, typeNames.size()); assertEquals(linesName, typeNames.get(0)); dataStore.createSchema(super.pointsType); typeNames = getTypeNames(Ref.HEAD); assertTrue(typeNames.isEmpty()); typeNames = getTypeNames(branchName); assertEquals(2, typeNames.size()); assertTrue(typeNames.contains(linesName)); assertTrue(typeNames.contains(pointsName)); }
@Test public void testCreateBranchWithTheSameNameAsExistingBranch() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true).call(); exception.expect(IllegalArgumentException.class); geogig.command(BranchCreateOp.class).setName("branch1").call(); }
@Test public void testOrphan() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); Ref branch1 = geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true) .setOrphan(true).call(); assertEquals(ObjectId.NULL, branch1.getObjectId()); assertEquals(Ref.HEADS_PREFIX + "branch1", branch1.getName()); } }
@Test public void testCreateBranchWithTheSameNameAsExistingBranchAndForce() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); geogig.command(BranchCreateOp.class).setName("branch1").call(); insertAndAdd(points2); RevCommit newCommit = geogig.command(CommitOp.class).setMessage("Commit2").call(); geogig.command(BranchCreateOp.class).setName("branch1").setForce(true).call(); Optional<Ref> branch1 = geogig.command(RefParse.class).setName("branch1").call(); assertTrue(branch1.isPresent()); assertEquals(branch1.get().getObjectId(), newCommit.getId()); }
@Test public void testCreateSchemaOnBranch() throws IOException { final String branchName = "testBranch"; geogig.command(BranchCreateOp.class).setName(branchName).setOrphan(true).call(); dataStore.setHead(branchName); final SimpleFeatureType featureType = super.linesType; dataStore.createSchema(featureType); List<String> typeNames; typeNames = getTypeNames(Ref.HEAD); assertTrue(typeNames.isEmpty()); typeNames = getTypeNames(branchName); assertEquals(1, typeNames.size()); assertEquals(linesName, typeNames.get(0)); dataStore.createSchema(super.pointsType); typeNames = getTypeNames(Ref.HEAD); assertTrue(typeNames.isEmpty()); typeNames = getTypeNames(branchName); assertEquals(2, typeNames.size()); assertTrue(typeNames.contains(linesName)); assertTrue(typeNames.contains(pointsName)); }
@Test public void testCreateBranchFromNonExistentCommit() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); exception.expect(IllegalArgumentException.class); geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true) .setSource("Nonexistent Commit").call(); }
@Test public void testCreateBranch() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true).call(); Optional<Ref> branch1 = geogig.command(RefParse.class).setName("branch1").call(); assertTrue(branch1.isPresent()); Optional<Ref> master = geogig.command(RefParse.class).setName("master").call(); assertEquals(master.get().getObjectId(), branch1.get().getObjectId()); }
protected void createBranch(String branch) { geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName(branch) .setProgressListener(SIMPLE_PROGRESS).call(); }