aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2023-07-25 12:09:40 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2023-07-25 12:09:40 -0400
commitc77fb93478b3acdc0f7e545f2d688b66b2a395e4 (patch)
tree6f9df8ffa1d96a52c42d0530500eef3e3d3e1a05 /org.eclipse.jgit.test
parent0f4af2bc3642b419b4e1b10b84624e9a3ed8a443 (diff)
parentec3d919aa5ae891edc3d5e7eafe09cf272801878 (diff)
downloadjgit-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.java24
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());