@Test public void testHistory_parameterCheck() throws Exception { // Make sure that we added at least one non-initial commit. repo.commit(HEAD, 0L, Author.UNKNOWN, SUMMARY, jsonUpserts[0]).join(); final Revision head = repo.normalizeNow(HEAD); List<Commit> commits; // Even though the range contains 1, if the path is specified and does not contain "/**", // it should not include the initial commit. commits = repo.history(HEAD, new Revision(1), "non_existing_path").join(); assertThat(commits).hasSize(0); // Should include the initial empty commit if the range contain 1 and the path contains "/**". commits = repo.history(HEAD, HEAD, "/**").join(); assertThat(commits).hasSize(1); // Should not include the initial empty commit if the range does not contain 1. commits = repo.history(HEAD, HEAD, "non_existing_path").join(); assertThat(commits).isEmpty(); assertThatThrownBy(() -> repo.history(head.forward(1), head.forward(2), "non_existing_path").join()) .isInstanceOf(CompletionException.class) .hasCauseInstanceOf(RevisionNotFoundException.class); assertThatThrownBy(() -> repo.history(head.forward(1), head.backward(1), "non_existing_path").join()) .isInstanceOf(CompletionException.class) .hasCauseInstanceOf(RevisionNotFoundException.class); assertThatThrownBy(() -> repo.history(null, HEAD, "non_existing_path").join()) .isInstanceOf(CompletionException.class) .hasCauseInstanceOf(NullPointerException.class); assertThatThrownBy(() -> repo.history(HEAD, null, "non_existing_path").join()) .isInstanceOf(CompletionException.class) .hasCauseInstanceOf(NullPointerException.class); }
previousNonEmptyRevision = commits.get(0).revision().backward(1); "mismatching revision: %s (expected: %s)", revision.major(), i); final Revision baseRevision = revision.backward(1); final Collection<Change<?>> changes = blockingDiff(previousNonEmptyRevision, revision, Repository.ALL_PATH).values();
previousNonEmptyRevision = commits.get(0).revision().backward(1); "mismatching revision: %s (expected: %s)", revision.major(), i); final Revision baseRevision = revision.backward(1); final Collection<Change<?>> changes = blockingDiff(previousNonEmptyRevision, revision, Repository.ALL_PATH).values();
previousNonEmptyRevision = commits.get(0).revision().backward(1); "mismatching revision: %s (expected: %s)", revision.major(), i); final Revision baseRevision = revision.backward(1); final Collection<Change<?>> changes = blockingDiff(previousNonEmptyRevision, revision, Repository.ALL_PATH).values();
/** * Run a sequence of add operation on the same path, valid the diff after each push. */ @Test public void testDiff_add() throws Exception { final String jsonPath = jsonUpserts[0].path(); final String textPath = textUpserts[0].path(); Revision prevRevison = repo.commit(HEAD, 0L, Author.UNKNOWN, SUMMARY, jsonUpserts[0], textUpserts[0]).join(); for (int i = 1; i < NUM_ITERATIONS; i++) { final Revision currRevision = repo.commit(HEAD, 0L, Author.UNKNOWN, SUMMARY, jsonPatches[i], textPatches[i]).join(); final Map<String, Change<?>> diff = repo.diff(prevRevison, currRevision, Repository.ALL_PATH).join(); assertThat(diff).hasSize(2) .containsEntry(jsonPath, jsonPatches[i]) .containsEntry(textPath, textPatches[i]); final Map<String, Change<?>> diff2 = repo.diff(HEAD.backward(1), HEAD, Repository.ALL_PATH).join(); assertThat(diff2).isEqualTo(diff); prevRevison = currRevision; } }
/** * Run a sequence of modification on the same path, validate the diff after each push. */ @Test public void testDiff_modify() throws Exception { final String jsonNodePath = jsonPatches[0].path(); final String textNodePath = textPatches[0].path(); // initial commit Revision prevRevision = repo.commit(HEAD, 0L, Author.UNKNOWN, SUMMARY, jsonPatches[0], textPatches[0]).join(); for (int i = 1; i < NUM_ITERATIONS; i++) { final Revision currRevision = repo.commit(HEAD, 0L, Author.UNKNOWN, SUMMARY, jsonPatches[i], textPatches[i]).join(); final Map<String, Change<?>> changes = repo.diff(prevRevision, currRevision, allPattern).join(); assertThat(changes).hasSize(2) .containsEntry(jsonNodePath, jsonPatches[i]) .containsEntry(textNodePath, textPatches[i]); final Map<String, Change<?>> changesRelative = repo.diff(HEAD.backward(1), HEAD, allPattern).join(); assertThat(changesRelative).isEqualTo(changes); prevRevision = currRevision; } }
/** * Run a sequence of remove operation on the same path, valid the diff after each push. */ @Test public void testDiff_remove() throws Exception { // add all files into repository Revision lastRevision = null; for (int i = 0; i < NUM_ITERATIONS; i++) { lastRevision = repo.commit(HEAD, 0L, Author.UNKNOWN, SUMMARY, jsonUpserts[i], textUpserts[i]).join(); } Revision prevRevison = lastRevision; for (int i = 1; i < NUM_ITERATIONS; i++) { final String jsonPath = jsonUpserts[i].path(); final String textPath = textUpserts[i].path(); final Change<Void> jsonRemoval = Change.ofRemoval(jsonPath); final Change<Void> textRemoval = Change.ofRemoval(textPath); final Revision currRevision = repo.commit(HEAD, 0L, Author.UNKNOWN, SUMMARY, jsonRemoval, textRemoval).join(); final Map<String, Change<?>> changes = repo.diff(prevRevison, currRevision, Repository.ALL_PATH).join(); assertThat(changes).hasSize(2) .containsEntry(jsonPath, jsonRemoval) .containsEntry(textPath, textRemoval); final Map<String, Change<?>> changesRelative = repo.diff(HEAD.backward(1), HEAD, allPattern).join(); assertThat(changesRelative).isEqualTo(changes); prevRevison = currRevision; } }
final Revision expectedRevision = previousRevision.backward(1); if (!currentRevision.equals(expectedRevision)) { throw new StorageException("mismatching revision: " + gitRepo.getDirectory() +
final Revision expectedRevision = previousRevision.backward(1); if (!currentRevision.equals(expectedRevision)) { throw new StorageException("mismatching revision: " + gitRepo.getDirectory() +
final Revision expectedRevision = previousRevision.backward(1); if (!currentRevision.equals(expectedRevision)) { throw new StorageException("mismatching revision: " + gitRepo.getDirectory() +