List of usage examples for org.eclipse.jgit.errors StopWalkException INSTANCE
StopWalkException INSTANCE
To view the source code for org.eclipse.jgit.errors StopWalkException INSTANCE.
Click Source Link
From source file:de.blizzy.documentr.page.PageStore.java
License:Open Source License
private Set<String> getBranchesWithCommit(final RevCommit commit, List<String> allBranches, Repository centralRepo) {//from w w w. ja v a2 s . c om final Set<String> result = Sets.newHashSet(); for (final String branch : allBranches) { CommitFilter matcher = new CommitFilter() { @Override public boolean include(RevWalk revWalk, RevCommit revCommit) { if (revCommit.equals(commit)) { result.add(branch); throw StopWalkException.INSTANCE; } return true; } }; CommitFinder finder = new CommitFinder(centralRepo); finder.setMatcher(matcher); finder.findFrom(branch); } return result; }
From source file:org.gitective.core.filter.commit.CommitFilter.java
License:Open Source License
/** * Return the include value given unless include is false and this filter is * configured to stop the search when a commit is not included. * * @param include/*from w w w . java 2s.c o m*/ * @return include parameter value */ protected boolean include(final boolean include) { if (!include && stop) throw StopWalkException.INSTANCE; return include; }
From source file:org.gitective.tests.CommitFinderTest.java
License:Open Source License
/** * Test filter throwing a {@link StopWalkException} and it being suppressed * and the walk stopping//from w w w. j av a 2 s. com * * @throws Exception */ @Test public void suppressedStopWalkExceptionThrownByMatcher() throws Exception { add("test.txt", "content"); CommitFinder finder = new CommitFinder(testRepo); CommitCountFilter count = new CommitCountFilter(); finder.setFilter(new AndCommitFilter(new CommitFilter() { public boolean include(RevWalk walker, RevCommit cmit) throws IOException { throw StopWalkException.INSTANCE; } public RevFilter clone() { return this; } }, count)); finder.find(); assertEquals(0, count.getCount()); }
From source file:org.gitective.tests.DiffTest.java
License:Open Source License
/** * Test diffs introduced by second commit * * @throws Exception/* w ww. j av a 2 s . c om*/ */ @Test public void second() throws Exception { add("test.txt", "content"); add("test.txt", "content2"); final AtomicReference<Collection<DiffEntry>> ref = new AtomicReference<Collection<DiffEntry>>(); CommitDiffFilter filter = new CommitDiffFilter() { public boolean include(RevCommit commit, Collection<DiffEntry> diffs) { ref.set(diffs); throw StopWalkException.INSTANCE; } }; new CommitFinder(testRepo).setFilter(filter).find(); Collection<DiffEntry> diffs = ref.get(); assertNotNull(diffs); assertEquals(1, diffs.size()); DiffEntry diff = diffs.iterator().next(); assertEquals(ChangeType.MODIFY, diff.getChangeType()); assertEquals("test.txt", diff.getOldPath()); assertEquals("test.txt", diff.getNewPath()); }
From source file:org.gitective.tests.DiffTest.java
License:Open Source License
/** * Test diffs introduced by merge commit * * @throws Exception//from w w w.ja va 2 s .c om */ @Test public void merge() throws Exception { add("test.txt", "a\nb\nc"); branch("test"); add("test.txt", "a\nb\nc\nd"); checkout("master"); add("test.txt", "1\na\nb\nc"); merge("test"); final AtomicReference<Collection<DiffEntry>> ref = new AtomicReference<Collection<DiffEntry>>(); CommitDiffFilter filter = new CommitDiffFilter() { public boolean include(RevCommit commit, Collection<DiffEntry> diffs) { ref.set(diffs); throw StopWalkException.INSTANCE; } }; new CommitFinder(testRepo).setFilter(filter).find(); Collection<DiffEntry> diffs = ref.get(); assertNotNull(diffs); assertEquals(1, diffs.size()); DiffEntry diff = diffs.iterator().next(); assertEquals(ChangeType.MODIFY, diff.getChangeType()); assertEquals("test.txt", diff.getOldPath()); assertEquals("test.txt", diff.getNewPath()); }