TreeRevFilterTest: Simplify filter used
TreeRevFilterTest uses an unncessarily complicated TreeFilter - an AndTreeFilter - when it should be as simple as possible because this class tests TreeRevFilter, not AndTreeFilter. Replace the filter with a simpler one. Change-Id: I3256a65f6e0042d32fd76a9224b79a835674ff3a Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
This commit is contained in:
parent
b138f16945
commit
91979f93fa
|
@ -46,25 +46,15 @@
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.eclipse.jgit.revwalk.filter.OrRevFilter;
|
||||
import org.eclipse.jgit.revwalk.filter.RevFilter;
|
||||
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.junit.Test;
|
||||
|
||||
public class TreeRevFilterTest extends RevWalkTestCase {
|
||||
private RevFilter treeRevFilter(String path) {
|
||||
return new TreeRevFilter(rw, treeFilter(path));
|
||||
}
|
||||
|
||||
private static TreeFilter treeFilter(String path) {
|
||||
return AndTreeFilter.create(
|
||||
PathFilterGroup.createFromStrings(Collections.singleton(path)),
|
||||
TreeFilter.ANY_DIFF);
|
||||
private RevFilter treeRevFilter() {
|
||||
return new TreeRevFilter(rw, TreeFilter.ANY_DIFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -73,7 +63,7 @@ public void testStringOfPearls_FilePath1()
|
|||
RevCommit a = commit(tree(file("d/f", blob("a"))));
|
||||
RevCommit b = commit(tree(file("d/f", blob("a"))), a);
|
||||
RevCommit c = commit(tree(file("d/f", blob("b"))), b);
|
||||
rw.setRevFilter(treeRevFilter("d/f"));
|
||||
rw.setRevFilter(treeRevFilter());
|
||||
markStart(c);
|
||||
|
||||
assertCommit(c, rw.next());
|
||||
|
@ -91,7 +81,7 @@ public void testStringOfPearls_FilePath2() throws Exception {
|
|||
RevCommit b = commit(tree(file("d/f", blob("a"))), a);
|
||||
RevCommit c = commit(tree(file("d/f", blob("b"))), b);
|
||||
RevCommit d = commit(tree(file("d/f", blob("b"))), c);
|
||||
rw.setRevFilter(treeRevFilter("d/f"));
|
||||
rw.setRevFilter(treeRevFilter());
|
||||
markStart(d);
|
||||
|
||||
// d was skipped
|
||||
|
@ -111,7 +101,7 @@ public void testStringOfPearls_DirPath2() throws Exception {
|
|||
RevCommit b = commit(tree(file("d/f", blob("a"))), a);
|
||||
RevCommit c = commit(tree(file("d/f", blob("b"))), b);
|
||||
RevCommit d = commit(tree(file("d/f", blob("b"))), c);
|
||||
rw.setRevFilter(treeRevFilter("d"));
|
||||
rw.setRevFilter(treeRevFilter());
|
||||
markStart(d);
|
||||
|
||||
// d was skipped
|
||||
|
@ -136,7 +126,7 @@ public void testStringOfPearls_FilePath3() throws Exception {
|
|||
RevCommit g = commit(tree(file("d/f", blob("b"))), f);
|
||||
RevCommit h = commit(tree(file("d/f", blob("b"))), g);
|
||||
RevCommit i = commit(tree(file("d/f", blob("c"))), h);
|
||||
rw.setRevFilter(treeRevFilter("d/f"));
|
||||
rw.setRevFilter(treeRevFilter());
|
||||
markStart(i);
|
||||
|
||||
assertCommit(i, rw.next());
|
||||
|
@ -156,7 +146,7 @@ public void testStringOfPearls_FilePath3() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testPathFilterOrOtherFilter() throws Exception {
|
||||
RevFilter pathFilter = treeRevFilter("d/f");
|
||||
RevFilter pathFilter = treeRevFilter();
|
||||
RevFilter skipFilter = SkipRevFilter.create(1);
|
||||
RevFilter orFilter = OrRevFilter.create(skipFilter, pathFilter);
|
||||
|
||||
|
|
Loading…
Reference in New Issue