@Test public void testCreateBranchFromSomethingOtherThanCommit() throws Exception { insertAndAdd(points1); RevCommit c1 = geogig.command(CommitOp.class).setMessage("Commit1").call(); insertAndAdd(points2); geogig.command(CommitOp.class).setMessage("Commit2").call(); insertAndAdd(points3); geogig.command(CommitOp.class).setMessage("Commit3").call(); exception.expect(IllegalArgumentException.class); geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true) .setSource(c1.getTreeId().toString()).call(); }
private RevCommit callCommit() { final CommitOp commitOp = context.command(CommitOp.class).setAll(true) .setAuthor(authorName, authorEmail).setMessage(commitMessage); commitOp.setProgressListener(getProgressListener()); return commitOp.call(); }
private RevCommit createCommits(int numCommits, String branchName) { RevCommit commit = null; for (int i = 1; i <= numCommits; i++) { commit = geogig.command(CommitOp.class).setAllowEmpty(true) .setMessage("Commit " + i + " in branch " + branchName).call(); } return commit; }
private RevCommit commitAllowEmpty(String message) { return geogig.command(CommitOp.class).setAllowEmpty(true).call(); }
command.setAllowEmpty(true); String message = ""; if (changeset.getComment().isPresent()) { message = "changeset " + changeset.getId(); command.setMessage(message); final String userName = changeset.getUserName(); command.setAuthor(userName, null); command.setAuthorTimestamp(changeset.getCreated()); command.setAuthorTimeZoneOffset(0);// osm timestamps are in GMT command.setCommitter(userName, null); command.setCommitterTimestamp(changeset.getClosed().get()); command.setCommitterTimeZoneOffset(0);// osm timestamps are in GMT RevCommit commit = command.call(); Ref head = geogig.command(RefParse.class).setName(Ref.HEAD).call().get(); Preconditions.checkState(commit.getId().equals(head.getObjectId()));
ProgressListener progress = cli.getProgressListener(); try { CommitOp commitOp = geogig.command(CommitOp.class).setMessage(message).setAmend(amend) .setAllowEmpty(allowEmpty); if (commitTimestamp != null && !Strings.isNullOrEmpty(commitTimestamp)) { Long millis = geogig.command(ParseTimestamp.class).setString(commitTimestamp) .call(); commitOp.setCommitterTimestamp(millis.longValue()); checkParameter(TYPE.COMMIT.equals(type), "Provided reference does not resolve to a commit"); commitOp.setCommit(geogig.getRepository().getCommit(commitId.get())); commit = commitOp.setPathFilters(pathFilters).setProgressListener(progress).call(); } catch (NothingToCommitException | IllegalStateException notificationError) {
@Test public void testFilterNamespaceNoChanges() throws Exception { // two commits on different trees insertAndAdd(points1); final RevCommit commit1 = geogig.command(CommitOp.class).setAll(true).call(); insertAndAdd(lines1); final RevCommit commit2 = geogig.command(CommitOp.class).setAll(true).call(); diffOp.setOldVersion(commit1.getId()).setNewVersion(commit2.getId()); diffOp.setFilter(pointsName); try (AutoCloseableIterator<DiffEntry> diffs = diffOp.call()) { assertFalse(diffs.hasNext()); } }
@Test public void testAmendNoChanges() throws Exception { final ObjectId id = insertAndAdd(points1); final RevCommit commit1 = geogig.command(CommitOp.class).setMessage("Message").call(); { assertCommit(commit1, null, null, null); assertEquals(id, repo.getRootTreeChild(appendChild(pointsName, idP1)).get().getObjectId()); assertNotNull(repo.objectDatabase().get(id)); } exception.expect(IllegalArgumentException.class); exception.expectMessage( "You must specify a new commit message, timestamp, or commit to reuse when amending a commit with no changes."); geogig.command(CommitOp.class).setAmend(true).call(); }
@Override protected void setUpInternal() throws Exception { dataStore = new GeoGigDataStore(geogig.getRepository()); dataStore.createSchema(super.pointsType); dataStore.createSchema(super.linesType); insertAndAdd(points1, points2, points3, lines1, lines2, lines3); geogig.command(CommitOp.class).setAuthor("yo", "yo@test.com") .setCommitter("me", "me@test.com").setMessage("initial import").call(); pointsSource = dataStore.getFeatureSource(pointsName); linesSource = dataStore.getFeatureSource(linesName); }
@Test public void testAmendReUseCommit() throws Exception { final ObjectId id = insertAndAdd(points1); final RevCommit commit1 = geogig.command(CommitOp.class).setMessage("Message").call(); { assertCommit(commit1, null, null, null); assertEquals(id, repo.getRootTreeChild(appendChild(pointsName, idP1)).get().getObjectId()); assertNotNull(repo.objectDatabase().get(id)); } final RevCommit commit2 = geogig.command(CommitOp.class).setAmend(true).setCommit(commit1) .call(); { assertCommit(commit2, null, "groldan", "Message"); Optional<RevFeature> p1 = geogig.command(RevObjectParse.class) .setRefSpec("HEAD:" + appendChild(pointsName, idP1)).call(RevFeature.class); assertTrue(p1.isPresent()); assertEquals(id, p1.get().getId()); assertEquals(commit1.getAuthor(), commit2.getAuthor()); assertEquals(commit1.getCommitter().getName(), commit2.getCommitter().getName()); assertEquals(commit1.getCommitter().getEmail(), commit2.getCommitter().getEmail()); assertEquals(commit1.getMessage(), commit2.getMessage()); assertEquals(commit1.getParentIds(), commit2.getParentIds()); assertEquals(commit1.getTreeId(), commit2.getTreeId()); } Iterator<RevCommit> log = geogig.command(LogOp.class).call(); assertTrue(log.hasNext()); log.next(); assertFalse(log.hasNext()); }
final RevCommit commit1 = geogig.command(CommitOp.class).setMessage("Message").call(); final RevCommit commit2 = geogig.command(CommitOp.class).setAmend(true) .setCommitterTimestamp(newTimestamp).call();
@Test public void testCommitUsingCommitAndMessage() throws Exception { String message = "A message"; insertAndAdd(points1); final RevCommit commit = geogig.command(CommitOp.class) .setCommitter("anothercommitter", "anothercommitter@boundlessgeo.com").call(); insertAndAdd(points2); RevCommit commit2 = geogig.command(CommitOp.class).setCommit(commit).setMessage(message) .call(); assertNotSame(commit.getMessage(), commit2.getMessage()); assertEquals(commit.getAuthor(), commit2.getAuthor()); assertNotSame(commit.getCommitter(), commit2.getCommitter()); assertEquals(message, commit2.getMessage()); }
if (conflictsAlreadyChecked || testMergeDone) { if (testMergeDone && this.message != null) { RevCommit ammended = transaction.command(CommitOp.class).setAmend(true) .setMessage(message).call(); setRef(transaction, testMergeRef, ammended.getId()); preStatus = preStatus.withMergeCommit(Optional.of(ammended.getId())); if (isNothingToCommit(pullResult)) { if (message != null) { transaction.command(CommitOp.class).setAmend(true).setMessage(message) .setProgressListener(progress).call();
@Test public void testExplicitTimeStamp() throws Exception { CommitOp commitCommand = geogig.command(CommitOp.class); commitCommand.setAuthorTimestamp(1000L); commitCommand.setAuthorTimeZoneOffset(-3); commitCommand.setCommitterTimestamp(2000L); commitCommand.setCommitterTimeZoneOffset(+4); commitCommand.setAllowEmpty(true); RevCommit commit = commitCommand.call(); assertEquals(1000L, commit.getAuthor().getTimestamp()); assertEquals(-3, commit.getAuthor().getTimeZoneOffset()); assertEquals(2000L, commit.getCommitter().getTimestamp()); assertEquals(+4, commit.getCommitter().getTimeZoneOffset()); }
@Test public void testCommitWithExplicitNullAuthorEmail() throws Exception { CommitOp commitCommand = geogig.command(CommitOp.class); commitCommand.setAuthor("John Doe", null); commitCommand.setAllowEmpty(true); RevCommit commit = commitCommand.call(); assertFalse(commit.getAuthor().getEmail().isPresent()); assertEquals("groldan", commit.getCommitter().getName().get()); assertEquals("groldan@boundlessgeo.com", commit.getCommitter().getEmail().get()); assertEquals("John Doe", commit.getAuthor().getName().get()); }
@Test public void testCancel() throws Exception { ProgressListener listener1 = mock(ProgressListener.class); when(listener1.isCanceled()).thenReturn(true); ProgressListener listener2 = mock(ProgressListener.class); when(listener2.isCanceled()).thenReturn(false, true); ProgressListener listener3 = mock(ProgressListener.class); when(listener3.isCanceled()).thenReturn(false, false, true); CommitOp commitCommand1 = geogig.command(CommitOp.class); commitCommand1.setProgressListener(listener1); assertNull(commitCommand1.setAllowEmpty(true).call()); CommitOp commitCommand2 = geogig.command(CommitOp.class); commitCommand2.setProgressListener(listener2); assertNull(commitCommand2.setAllowEmpty(true).call()); CommitOp commitCommand3 = geogig.command(CommitOp.class); commitCommand3.setProgressListener(listener3); assertNull(commitCommand3.setAllowEmpty(true).call()); verify(listener1, times(1)).isCanceled(); verify(listener2, times(2)).isCanceled(); verify(listener3, times(3)).isCanceled(); }
private List<RevCommit> insertAndCommit(List<? extends Feature> features, final int featuresPerCommit) throws Exception { List<RevCommit> commits = new LinkedList<>(); int i = 0; for (List<? extends Feature> partition : Iterables.partition(features, featuresPerCommit)) { insert(remoteRepo, partition); add(remoteRepo); String from = partition.get(0).getIdentifier().toString(); String to = partition.get(partition.size() - 1).getIdentifier().toString(); String message = String.format("commit features %s to %s", from, to); RevCommit commit = remoteRepo.command(CommitOp.class).setMessage(message) .setProgressListener(SIMPLE_PROGRESS).call(); commits.add(0, commit); i++; } return commits; }
@Test public void testCommitterFilter() throws Exception { insertAndAdd(points1); final RevCommit firstCommit = geogig.command(CommitOp.class) .setCommitter("firstcommitter", "firstcommitter@boundlessgeo.com").call(); insertAndAdd(lines1); final RevCommit secondCommit = geogig.command(CommitOp.class) .setAuthor("secondcommitter", "secondcommitter@boundlessgeo.com").call(); Iterator<RevCommit> iterator = logOp.setAuthor("firstcommitter").call(); assertNotNull(iterator); assertTrue(iterator.hasNext()); assertEquals(firstCommit, iterator.next()); assertFalse(iterator.hasNext()); iterator = logOp.setAuthor("secondcommitter").call(); assertNotNull(iterator); assertTrue(iterator.hasNext()); assertEquals(secondCommit, iterator.next()); assertFalse(iterator.hasNext()); }
@Test public void testCommitUsingCommit() throws Exception { insertAndAdd(points1); final RevCommit commit = geogig.command(CommitOp.class) .setCommitter("anothercommitter", "anothercommitter@boundlessgeo.com").call(); insertAndAdd(points2); RevCommit commit2 = geogig.command(CommitOp.class).setCommit(commit).call(); assertEquals(commit.getMessage(), commit2.getMessage()); assertEquals(commit.getAuthor(), commit2.getAuthor()); assertNotSame(commit.getCommitter(), commit2.getCommitter()); }