/** * Search the commits starting at the commit that HEAD current references. * * @return this service */ public CommitFinder find() { return findFrom(HEAD); }
/** * Search the commits starting from the given commit id. * * @param start * @return this service */ public CommitFinder findFrom(final ObjectId start) { return findBetween(start, (ObjectId) null); }
CommitFinder finder = new CommitFinder(r); CommitListFilter filter = new CommitListFilter(); if (Strings.isNotBlank(path)) { finder.setFilter(PathFilterUtils.and(path)); finder.setFilter(filter); finder.setFilter(new CommitLimitFilter(limit).setStop(true)); finder.findFrom(objectId); } else { if (Strings.isNotBlank(branch)) { ObjectId branchObjectId = getBranchObjectId(git, branch); if (branchObjectId != null) { finder = finder.findFrom(branchObjectId); } else { finder = finder.findInBranches(); finder.find();
CommitFinder finder = new CommitFinder(r); CommitListFilter filter = new CommitListFilter(); finder.setFilter(filter); finder.find(); List<RevCommit> commits = filter.getCommits(); commits = filterAndSortCommits(name, branch, commits);
public void getCommits(String treeName) { Repository repository = new FileRepository("/home/felipe/git/testRepository/.git"); AndCommitFilter filters = new AndCommitFilter(); CommitListFilter revCommits = new CommitListFilter(); filters.add(revCommits); CommitFinder finder = new CommitFinder(repository); finder.setFilter(filters); finder.findFrom(treeName); for(RevCommit revCommit : revCommits){ System.out.println(revCommit.getName()); } }
/** * Search the commits starting at the commit that each branch is * referencing. * <p> * Repositories that have no branches will be ignored. * * @return this finder */ public CommitFinder findInBranches() { final Repository[] repos = repositories; final int repoCount = repositories.length; Repository repo; for (int i = 0; i < repoCount; i++) { repo = repos[i]; final Collection<RevCommit> commits = CommitUtils.getBranches(repo); if (commits.isEmpty()) continue; final RevWalk walk = createWalk(repo); try { walk.markStart(commits); walk(walk); } catch (IOException e) { throw new GitException(e, repo); } finally { walk.close(); } } return this; }
CommitFinder finder = new CommitFinder(r); CommitListFilter filter = new CommitListFilter(); if (Strings.isNotBlank(path)) { finder.setFilter(PathFilterUtils.and(path)); finder.setFilter(filter); finder.setFilter(new CommitLimitFilter(limit).setStop(true)); finder.findFrom(objectId); } else { if (Strings.isNotBlank(branch)) { ObjectId branchObjectId = getBranchObjectId(git); if (branchObjectId != null) { finder = finder.findFrom(branchObjectId); } else { finder = finder.findInBranches(); finder.find();
/** * Search the commits starting at the commit that each tag is referencing. * <p> * Repositories that have no tags will be ignored. * * @return this finder */ public CommitFinder findInTags() { final Repository[] repos = repositories; final int repoCount = repositories.length; Repository repo; for (int i = 0; i < repoCount; i++) { repo = repos[i]; final Collection<RevCommit> commits = CommitUtils.getTags(repo); if (commits.isEmpty()) continue; final RevWalk walk = createWalk(repo); try { walk.markStart(commits); walk(walk); } catch (IOException e) { throw new GitException(e, repo); } finally { walk.close(); } } return this; }
/** * Walk the commits between the start commit id and end commit id. * * @param repository * @param start * must be non-null * @param end * @return this service */ protected CommitFinder walk(final Repository repository, final ObjectId start, final ObjectId end) { if (start == null) throw new IllegalArgumentException( Assert.formatNotNull("Starting commit id")); final RevWalk walk = createWalk(repository); try { walk.markStart(walk.parseCommit(start)); if (end != null) walk.markUninteresting(walk.parseCommit(end)); walk(walk); } catch (IOException e) { throw new GitException(e, repository); } finally { walk.close(); } return this; }
/** * Search the commits starting at HEAD and ending with the given revision * * @param end * @return this service */ public CommitFinder findUntil(final String end) { return findBetween(HEAD, end); }
/** * Search the commits starting from the given revision. * * @param start * @return this service */ public CommitFinder findFrom(final String start) { return findBetween(start, (ObjectId) null); }
/** * Search the commits starting at HEAD and ending with the given commit id * * @param end * @return this service */ public CommitFinder findUntil(final ObjectId end) { return findBetween(HEAD, end); } }