本文整理汇总了Java中org.eclipse.jgit.revwalk.RevWalk.setRevFilter方法的典型用法代码示例。如果您正苦于以下问题:Java RevWalk.setRevFilter方法的具体用法?Java RevWalk.setRevFilter怎么用?Java RevWalk.setRevFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.revwalk.RevWalk
的用法示例。
在下文中一共展示了RevWalk.setRevFilter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSingleBaseCommit
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
private GitRevisionInfo getSingleBaseCommit (RevWalk walk, List<RevCommit> commits) throws IOException {
while (commits.size() > 1) {
walk.reset();
for (RevCommit c : commits) {
walk.markStart(walk.parseCommit(c));
}
walk.setRevFilter(RevFilter.MERGE_BASE);
commits.clear();
for (RevCommit commit = walk.next(); commit != null; commit = walk.next()) {
commits.add(commit);
}
}
if (commits.isEmpty()) {
return null;
} else {
return getClassFactory().createRevisionInfo(commits.get(0), getRepository());
}
}
示例2: getCommonAncestor
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
/**
* Finds the common base for the given commit "a" and the given commit "b"
*
* @param walk
* - used to browse through commits
* @param a
* - commit "a"
* @param b
* - commit "b"
* @return the bese commit
* @throws IncorrectObjectTypeException
* @throws IOException
*/
private RevCommit getCommonAncestor(RevWalk walk, RevCommit a, RevCommit b)
throws IOException {
walk.reset();
walk.setRevFilter(RevFilter.MERGE_BASE);
walk.markStart(a);
walk.markStart(b);
final RevCommit base = walk.next();
if (base == null)
return null;
final RevCommit base2 = walk.next();
if (base2 != null) {
throw new NoMergeBaseException(MergeBaseFailureReason.MULTIPLE_MERGE_BASES_NOT_SUPPORTED,
MessageFormat.format(JGitText.get().multipleMergeBasesFor, a.name(), b.name(), base.name(), base2.name()));
}
return base;
}
示例3: fetchAndCreateNewRevsWalk
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
public RevWalk fetchAndCreateNewRevsWalk(Repository repository, String branch) throws Exception {
List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>();
for (Ref ref : repository.getAllRefs().values()) {
String refName = ref.getName();
if (refName.startsWith(REMOTE_REFS_PREFIX)) {
currentRemoteRefs.add(ref.getObjectId());
}
}
List<TrackingRefUpdate> newRemoteRefs = this.fetch(repository);
RevWalk walk = new RevWalk(repository);
for (TrackingRefUpdate newRef : newRemoteRefs) {
if (branch == null || newRef.getLocalName().endsWith("/" + branch)) {
walk.markStart(walk.parseCommit(newRef.getNewObjectId()));
}
}
for (ObjectId oldRef : currentRemoteRefs) {
walk.markUninteresting(walk.parseCommit(oldRef));
}
walk.setRevFilter(commitsFilter);
return walk;
}
示例4: createAllRevsWalk
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
public RevWalk createAllRevsWalk(Repository repository, String branch) throws Exception {
List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>();
for (Ref ref : repository.getAllRefs().values()) {
String refName = ref.getName();
if (refName.startsWith(REMOTE_REFS_PREFIX)) {
if (branch == null || refName.endsWith("/" + branch)) {
currentRemoteRefs.add(ref.getObjectId());
}
}
}
RevWalk walk = new RevWalk(repository);
for (ObjectId newRef : currentRemoteRefs) {
walk.markStart(walk.parseCommit(newRef));
}
walk.setRevFilter(commitsFilter);
return walk;
}
示例5: fetchAndCreateNewRevsWalk
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
public RevWalk fetchAndCreateNewRevsWalk(Repository repository, String branch) throws Exception {
List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>();
for (Ref ref : repository.getAllRefs().values()) {
String refName = ref.getName();
if (refName.startsWith(REMOTE_REFS_PREFIX)) {
currentRemoteRefs.add(ref.getObjectId());
}
}
List<TrackingRefUpdate> newRemoteRefs = this.fetch(repository);
RevWalk walk = new RevWalk(repository);
for (TrackingRefUpdate newRef : newRemoteRefs) {
if (branch == null || newRef.getLocalName().endsWith("/" + branch)) {
walk.markStart(walk.parseCommit(newRef.getNewObjectId()));
}
}
for (ObjectId oldRef : currentRemoteRefs) {
walk.markUninteresting(walk.parseCommit(oldRef));
}
walk.setRevFilter(commitsFilter);
return walk;
}
示例6: createAllRevsWalk
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
public RevWalk createAllRevsWalk(Repository repository, String branch) throws Exception {
List<ObjectId> currentRemoteRefs = new ArrayList<ObjectId>();
for (Ref ref : repository.getAllRefs().values()) {
String refName = ref.getName();
if (refName.startsWith(REMOTE_REFS_PREFIX)) {
if (branch == null || refName.endsWith("/" + branch)) {
currentRemoteRefs.add(ref.getObjectId());
}
}
}
RevWalk walk = new RevWalk(repository);
for (ObjectId newRef : currentRemoteRefs) {
walk.markStart(walk.parseCommit(newRef));
}
walk.setRevFilter(commitsFilter);
return walk;
}
示例7: listFiles
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
private void listFiles() throws GitException {
RevWalk revWalk = new RevWalk(repository);
TreeWalk walk = new TreeWalk(repository);
try {
List<GitFileInfo> result;
walk.reset();
walk.setRecursive(true);
RevCommit parentCommit = null;
if (revCommit.getParentCount() > 0) {
for (RevCommit commit : revCommit.getParents()) {
revWalk.markStart(revWalk.lookupCommit(commit));
}
revWalk.setRevFilter(RevFilter.MERGE_BASE);
Iterator<RevCommit> it = revWalk.iterator();
if (it.hasNext()) {
parentCommit = it.next();
}
if (parentCommit != null) {
walk.addTree(parentCommit.getTree().getId());
}
}
walk.addTree(revCommit.getTree().getId());
walk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, PathFilter.ANY_DIFF));
if (parentCommit != null) {
result = Utils.getDiffEntries(repository, walk, GitClassFactoryImpl.getInstance());
} else {
result = new ArrayList<GitFileInfo>();
while (walk.next()) {
result.add(new GitFileInfo(new File(repository.getWorkTree(), walk.getPathString()), walk.getPathString(), GitFileInfo.Status.ADDED, null, null));
}
}
this.modifiedFiles = result.toArray(new GitFileInfo[result.size()]);
} catch (IOException ex) {
throw new GitException(ex);
} finally {
revWalk.release();
walk.release();
}
}
示例8: applyCriteria
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
private void applyCriteria (RevWalk walk, SearchCriteria criteria,
final RevFlag partOfResultFlag, DiffConfig diffConfig) {
File[] files = criteria.getFiles();
if (files.length > 0) {
Collection<PathFilter> pathFilters = Utils.getPathFilters(getRepository().getWorkTree(), files);
if (!pathFilters.isEmpty()) {
if (criteria.isFollow() && pathFilters.size() == 1) {
walk.setTreeFilter(FollowFilter.create(pathFilters.iterator().next().getPath(), diffConfig));
} else {
walk.setTreeFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, PathFilterGroup.create(pathFilters)));
}
}
}
RevFilter filter;
if (criteria.isIncludeMerges()) {
filter = RevFilter.ALL;
} else {
filter = RevFilter.NO_MERGES;
}
filter = AndRevFilter.create(filter, new CancelRevFilter(monitor));
filter = AndRevFilter.create(filter, new RevFilter() {
@Override
public boolean include (RevWalk walker, RevCommit cmit) {
return cmit.has(partOfResultFlag);
}
@Override
public RevFilter clone () {
return this;
}
@Override
public boolean requiresCommitBody () {
return false;
}
});
String username = criteria.getUsername();
if (username != null && !(username = username.trim()).isEmpty()) {
filter = AndRevFilter.create(filter, OrRevFilter.create(CommitterRevFilter.create(username), AuthorRevFilter.create(username)));
}
String message = criteria.getMessage();
if (message != null && !(message = message.trim()).isEmpty()) {
filter = AndRevFilter.create(filter, MessageRevFilter.create(message));
}
Date from = criteria.getFrom();
Date to = criteria.getTo();
if (from != null && to != null) {
filter = AndRevFilter.create(filter, CommitTimeRevFilter.between(from, to));
} else if (from != null) {
filter = AndRevFilter.create(filter, CommitTimeRevFilter.after(from));
} else if (to != null) {
filter = AndRevFilter.create(filter, CommitTimeRevFilter.before(to));
}
// this must be at the end, limit filter must apply as the last
if (criteria.getLimit() != -1) {
filter = AndRevFilter.create(filter, MaxCountRevFilter.create(criteria.getLimit()));
}
walk.setRevFilter(filter);
}
示例9: countCommits
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
public int countCommits(Repository repository, String branch) throws Exception {
RevWalk walk = new RevWalk(repository);
try {
Ref ref = repository.findRef(REMOTE_REFS_PREFIX + branch);
ObjectId objectId = ref.getObjectId();
RevCommit start = walk.parseCommit(objectId);
walk.setRevFilter(RevFilter.NO_MERGES);
return RevWalkUtils.count(walk, start, null);
} finally {
walk.dispose();
}
}
示例10: countCommits
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
@Override
public int countCommits(Repository repository, String branch) throws Exception {
RevWalk walk = new RevWalk(repository);
try {
Ref ref = repository.findRef(REMOTE_REFS_PREFIX + branch);
ObjectId objectId = ref.getObjectId();
RevCommit start = walk.parseCommit(objectId);
walk.setRevFilter(RevFilter.NO_MERGES);
return RevWalkUtils.count(walk, start, null);
} finally {
walk.dispose();
}
}