summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorRonald Bhuleskar <funronald@google.com>2023-07-19 14:25:46 -0700
committerRonald Bhuleskar <funronald@google.com>2023-07-24 19:42:51 -0400
commitec3d919aa5ae891edc3d5e7eafe09cf272801878 (patch)
treeb1d883198f8e0caeaca5af98b0500ce73c5a474a /org.eclipse.jgit.test
parent3b77e33ad8f8206ff30a66ea2d15c3e1f1b731b2 (diff)
downloadjgit-ec3d919aa5ae891edc3d5e7eafe09cf272801878.tar.gz
jgit-ec3d919aa5ae891edc3d5e7eafe09cf272801878.zip
Identify a commit that generates a diffEntry on a rename Event.
When using FollowFilter's rename callback, a callback is generated with the diff. The caller that is interested in the renames knows what the diff's are but have no idea what commit generated that diff. This will allow FollowFilter's rename callback to track diffEntry for a given commit. Change-Id: If1e63ccd19fdcb9c58c59137110fe24e0ce023d2
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());