Browse Source

Merge "TreeRevFilterTest: Simplify filter used"

next
Jonathan Tan 5 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
0bf165b7b6
  1. 24
      org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/TreeRevFilterTest.java

24
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/TreeRevFilterTest.java

@ -46,25 +46,15 @@ package org.eclipse.jgit.revwalk;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import java.util.Collections;
import org.eclipse.jgit.revwalk.filter.OrRevFilter; import org.eclipse.jgit.revwalk.filter.OrRevFilter;
import org.eclipse.jgit.revwalk.filter.RevFilter; import org.eclipse.jgit.revwalk.filter.RevFilter;
import org.eclipse.jgit.revwalk.filter.SkipRevFilter; import org.eclipse.jgit.revwalk.filter.SkipRevFilter;
import org.eclipse.jgit.treewalk.filter.AndTreeFilter;
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
import org.eclipse.jgit.treewalk.filter.TreeFilter; import org.eclipse.jgit.treewalk.filter.TreeFilter;
import org.junit.Test; import org.junit.Test;
public class TreeRevFilterTest extends RevWalkTestCase { public class TreeRevFilterTest extends RevWalkTestCase {
private RevFilter treeRevFilter(String path) { private RevFilter treeRevFilter() {
return new TreeRevFilter(rw, treeFilter(path)); return new TreeRevFilter(rw, TreeFilter.ANY_DIFF);
}
private static TreeFilter treeFilter(String path) {
return AndTreeFilter.create(
PathFilterGroup.createFromStrings(Collections.singleton(path)),
TreeFilter.ANY_DIFF);
} }
@Test @Test
@ -73,7 +63,7 @@ public class TreeRevFilterTest extends RevWalkTestCase {
RevCommit a = commit(tree(file("d/f", blob("a")))); RevCommit a = commit(tree(file("d/f", blob("a"))));
RevCommit b = commit(tree(file("d/f", blob("a"))), a); RevCommit b = commit(tree(file("d/f", blob("a"))), a);
RevCommit c = commit(tree(file("d/f", blob("b"))), b); RevCommit c = commit(tree(file("d/f", blob("b"))), b);
rw.setRevFilter(treeRevFilter("d/f")); rw.setRevFilter(treeRevFilter());
markStart(c); markStart(c);
assertCommit(c, rw.next()); assertCommit(c, rw.next());
@ -91,7 +81,7 @@ public class TreeRevFilterTest extends RevWalkTestCase {
RevCommit b = commit(tree(file("d/f", blob("a"))), a); RevCommit b = commit(tree(file("d/f", blob("a"))), a);
RevCommit c = commit(tree(file("d/f", blob("b"))), b); RevCommit c = commit(tree(file("d/f", blob("b"))), b);
RevCommit d = commit(tree(file("d/f", blob("b"))), c); RevCommit d = commit(tree(file("d/f", blob("b"))), c);
rw.setRevFilter(treeRevFilter("d/f")); rw.setRevFilter(treeRevFilter());
markStart(d); markStart(d);
// d was skipped // d was skipped
@ -111,7 +101,7 @@ public class TreeRevFilterTest extends RevWalkTestCase {
RevCommit b = commit(tree(file("d/f", blob("a"))), a); RevCommit b = commit(tree(file("d/f", blob("a"))), a);
RevCommit c = commit(tree(file("d/f", blob("b"))), b); RevCommit c = commit(tree(file("d/f", blob("b"))), b);
RevCommit d = commit(tree(file("d/f", blob("b"))), c); RevCommit d = commit(tree(file("d/f", blob("b"))), c);
rw.setRevFilter(treeRevFilter("d")); rw.setRevFilter(treeRevFilter());
markStart(d); markStart(d);
// d was skipped // d was skipped
@ -136,7 +126,7 @@ public class TreeRevFilterTest extends RevWalkTestCase {
RevCommit g = commit(tree(file("d/f", blob("b"))), f); RevCommit g = commit(tree(file("d/f", blob("b"))), f);
RevCommit h = commit(tree(file("d/f", blob("b"))), g); RevCommit h = commit(tree(file("d/f", blob("b"))), g);
RevCommit i = commit(tree(file("d/f", blob("c"))), h); RevCommit i = commit(tree(file("d/f", blob("c"))), h);
rw.setRevFilter(treeRevFilter("d/f")); rw.setRevFilter(treeRevFilter());
markStart(i); markStart(i);
assertCommit(i, rw.next()); assertCommit(i, rw.next());
@ -156,7 +146,7 @@ public class TreeRevFilterTest extends RevWalkTestCase {
@Test @Test
public void testPathFilterOrOtherFilter() throws Exception { public void testPathFilterOrOtherFilter() throws Exception {
RevFilter pathFilter = treeRevFilter("d/f"); RevFilter pathFilter = treeRevFilter();
RevFilter skipFilter = SkipRevFilter.create(1); RevFilter skipFilter = SkipRevFilter.create(1);
RevFilter orFilter = OrRevFilter.create(skipFilter, pathFilter); RevFilter orFilter = OrRevFilter.create(skipFilter, pathFilter);

Loading…
Cancel
Save