diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2023-07-25 12:09:40 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2023-07-25 12:09:40 -0400 |
commit | c77fb93478b3acdc0f7e545f2d688b66b2a395e4 (patch) | |
tree | 6f9df8ffa1d96a52c42d0530500eef3e3d3e1a05 /org.eclipse.jgit.test | |
parent | 0f4af2bc3642b419b4e1b10b84624e9a3ed8a443 (diff) | |
parent | ec3d919aa5ae891edc3d5e7eafe09cf272801878 (diff) | |
download | jgit-c77fb93478b3acdc0f7e545f2d688b66b2a395e4.tar.gz jgit-c77fb93478b3acdc0f7e545f2d688b66b2a395e4.zip |
Merge "Identify a commit that generates a diffEntry on a rename Event."
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkFollowFilterTest.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkFollowFilterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkFollowFilterTest.java index c62136e64d..5203e3fbea 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkFollowFilterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkFollowFilterTest.java @@ -27,9 +27,17 @@ public class RevWalkFollowFilterTest extends RevWalkTestCase { private static class DiffCollector extends RenameCallback { List<DiffEntry> diffs = new ArrayList<>(); + List<RevCommit> commits = new ArrayList<>(); + @Override public void renamed(DiffEntry diff) { + throw new UnsupportedOperationException("unimplemented"); + } + + @Override + public void renamed(DiffEntry diff, RevCommit commit) { diffs.add(diff); + commits.add(commit); } } @@ -77,6 +85,7 @@ public class RevWalkFollowFilterTest extends RevWalkTestCase { assertNull(rw.next()); assertRenames("a->b"); + assertRenameCommits(renameCommit); } @Test @@ -108,6 +117,7 @@ public class RevWalkFollowFilterTest extends RevWalkTestCase { assertNull(rw.next()); assertRenames("c->a", "b->c", "a->b"); + assertRenameCommits(renameCommit3, renameCommit2, renameCommit1); } /** @@ -136,6 +146,20 @@ public class RevWalkFollowFilterTest extends RevWalkTestCase { } } + protected void assertRenameCommits(RevCommit... expectedCommits) { + Assert.assertEquals( + "Unexpected number of rename commits. Expected: " + + expectedCommits.length + ", actual: " + + diffCollector.diffs.size(), + expectedCommits.length, diffCollector.diffs.size()); + + for (int i = 0; i < expectedCommits.length; i++) { + RevCommit renameCommit = diffCollector.commits.get(i); + Assert.assertNotNull(renameCommit); + Assert.assertEquals(expectedCommits[i], renameCommit); + } + } + protected void assertNoRenames() { Assert.assertEquals("Found unexpected rename/copy diff", 0, diffCollector.diffs.size()); |