log.addRange(sId, fId); } else { log.add(fId);
Iterable<RevCommit> commitsToUse; try (Git git = new Git(repo)) { LogCommand cmd = git.log().addRange(upstreamCommit, headCommit); commitsToUse = cmd.call();
long countCommits( AnyObjectId a, AnyObjectId b ) throws IncorrectObjectTypeException, MissingObjectException, GitAPIException { return StreamSupport.stream( git.log().addRange( a, b ).call().spliterator(), true ).count(); } }
long countCommits( AnyObjectId a, AnyObjectId b ) throws IncorrectObjectTypeException, MissingObjectException, GitAPIException { return StreamSupport.stream( git.log().addRange( a, b ).call().spliterator(), true ).count(); }
long countCommits( AnyObjectId a, AnyObjectId b ) throws IncorrectObjectTypeException, MissingObjectException, GitAPIException { return StreamSupport.stream( git.log().addRange( a, b ).call().spliterator(), true ).count(); }
private List<RevCommit> getDiffingCommits(final RevCommit from, final RevCommit to) throws Exception { final RevCommit firstCommit = firstCommit(); final List<RevCommit> allInFrom = newArrayList(this.git.log().addRange(firstCommit, from).call()); final List<RevCommit> allInTo = newArrayList(this.git.log().addRange(firstCommit, to).call()); return newArrayList(filter(allInTo, not(in(allInFrom)))); }
private List<Ref> tagsBetweenFromAndTo(final ObjectId from, final ObjectId to) throws Exception { final List<Ref> tagList = this.git.tagList().call(); final List<RevCommit> icludedCommits = newArrayList(this.git.log().addRange(from, to).call()); final List<Ref> includedTags = newArrayList(); for (final Ref tag : tagList) { final ObjectId peeledTag = getPeeled(tag); if (icludedCommits.contains(peeledTag)) { includedTags.add(tag); } } return includedTags; }
/** * @inheritDoc */ @Override public Iterable<RevCommit> getCommitDifferential(Git git, String baseRef, String headRef) { Ref localRef = git.getRepository().getAllRefs().get(headRef); Ref upstreamRef = git.getRepository().getAllRefs().get(baseRef); try { return git.log().addRange(upstreamRef.getObjectId(), localRef.getObjectId()).call(); } catch (GitAPIException|MissingObjectException|IncorrectObjectTypeException e) { throw new RuntimeException("Failed to get commit differential between"+baseRef+" and "+headRef); } }
/** * Returns a list of Commits representing all changes since the last time the repo was * published. * * @return - List of Commit objects * @throws GitAPIException - failed * @throws IOException - failed */ public List<Commit> getUnpublishedCommits() throws GitAPIException, IOException { final List<Commit> commits = StreamSupport .stream(git.log() .addRange(getPublished().getPeeledObjectId(), git.getRepository().resolve("HEAD")) .call().spliterator(), false) .map(c -> new Commit(c.abbreviate(NAME_LENGTH).name(), c.getFullMessage(), null)) .collect(Collectors.toList()); Collections.reverse(commits); return commits; }
@Override public Map<String, RevTag> findTagsBetween(Git git, RevCommit c1, RevCommit c2) throws GitAPIException, IOException { Map<ObjectId, List<RevTag>> reverseReferences = new HashMap<>(); RevWalk walk = new RevWalk(git.getRepository()); for (Ref t : git.tagList().call()) { Ref peeled = git.getRepository().peel(t); if (peeled != null && peeled.getPeeledObjectId() != null) { if (!reverseReferences.containsKey(peeled.getPeeledObjectId())) { reverseReferences.put(peeled.getPeeledObjectId(), new LinkedList<RevTag>()); } reverseReferences.get(peeled.getPeeledObjectId()).add(walk.parseTag(t.getObjectId())); } } Map<String, RevTag> result = new HashMap<>(); Iterable<RevCommit> commits = git.log().addRange(c1, c2).call(); for (RevCommit commit : commits) { if (reverseReferences.containsKey(commit.getId())) { for (RevTag tag : reverseReferences.get(commit.getId())) { result.put(tag.getTagName(), tag); } } } return result; }
@Override public Map<String, RevTag> findTagsBetween(Git git, RevCommit c1, RevCommit c2) throws GitAPIException, IOException { Map<ObjectId, List<RevTag>> reverseReferences = new HashMap<>(); RevWalk walk = new RevWalk(git.getRepository()); for (Ref t : git.tagList().call()) { Ref peeled = git.getRepository().peel(t); if (peeled != null && peeled.getPeeledObjectId() != null) { if (!reverseReferences.containsKey(peeled.getPeeledObjectId())) { reverseReferences.put(peeled.getPeeledObjectId(), new LinkedList<RevTag>()); } reverseReferences.get(peeled.getPeeledObjectId()).add(walk.parseTag(t.getObjectId())); } } Map<String, RevTag> result = new HashMap<>(); Iterable<RevCommit> commits = git.log().addRange(c1, c2).call(); for (RevCommit commit : commits) { if (reverseReferences.containsKey(commit.getId())) { for (RevTag tag : reverseReferences.get(commit.getId())) { result.put(tag.getTagName(), tag); } } } return result; }
Iterable<RevCommit> commitsToUse; try (Git git = new Git(repo)) { LogCommand cmd = git.log().addRange(upstreamCommit, headCommit); commitsToUse = cmd.call();
Iterable<RevCommit> commitsToUse; try (Git git = new Git(repo)) { LogCommand cmd = git.log().addRange(upstreamCommit, headCommit); commitsToUse = cmd.call();
public static Set<String> extractJiraIssues(Repository repository, String sinceTagName, String untilTagName, String pattern) throws IOException, GitAPIException { try(Git git = new Git(repository)) { final RevCommit startCommitId = resolveCommitIdByTagName(repository, sinceTagName); if (startCommitId == null) { throw new IOException("cannot resolveCommitIdByTagName by " + sinceTagName); } ObjectId endCommitId = resolveCommitIdByTagName(repository, untilTagName); if (endCommitId == null) { endCommitId = repository.resolve(Constants.HEAD); } final Iterable<RevCommit> commits = git.log().addRange(startCommitId, endCommitId).call(); return extractJiraIssues(pattern, commits); } }
/** * Returns a list of commits between two references. * @param repoPath path to local git repository. * @param startRef start reference. * @param endRef end reference. * @return a list of commits. * @throws IOException if I/O error occurs. * @throws GitAPIException if an error occurs when accessing Git API. */ private static Set<RevCommit> getCommitsBetweenReferences(String repoPath, String startRef, String endRef) throws IOException, GitAPIException { final FileRepositoryBuilder builder = new FileRepositoryBuilder(); final Path path = Paths.get(repoPath); final Repository repo = builder.findGitDir(path.toFile()).readEnvironment().build(); final ObjectId startCommit = getActualRefObjectId(repo, startRef); Verify.verifyNotNull(startCommit, "Start reference \"" + startRef + "\" is invalid!"); final ObjectId endCommit = getActualRefObjectId(repo, endRef); final Iterable<RevCommit> commits = new Git(repo).log().addRange(startCommit, endCommit).call(); return Sets.newLinkedHashSet(commits); }
public static Iterable<RevCommit> getCommits( Iterable<File> dirs, String rangeStart, String rangeEnd, Repository repository) throws Exception { try (Git git = Git.wrap(repository)) { LogCommand logCommand = git.log(); for (File dir : dirs) { logCommand.addPath(_relativize(dir, repository)); } logCommand.addRange( repository.resolve(rangeStart), repository.resolve(rangeEnd)); return logCommand.call(); } }
public static Iterable<RevCommit> getJGitLogBetween(Repository repo, final ObjectId refFrom, final ObjectId refTo) throws IOException, GitAPIException { return refFrom != null ? new Git(repo).log().addRange(refFrom, refTo).call() : new Git(repo).log().add(refTo).call(); }
} else { LOGGER.debug("Retrieving revisions in range [{}, {}]", newHead.name(), oldHead.name()); logCommand.addRange(oldHead, newHead);
Iterable<RevCommit> mainChanges = fork.log().addRange(since, to).call(); List<RevCommit> userChanges = new LinkedList<>(); for (RevCommit rc : mainChanges) {
Iterable<RevCommit> mainChanges = fork.log().addRange(since, to).call(); List<RevCommit> userChanges = new LinkedList<>(); for (RevCommit rc : mainChanges) {