use of net.nemerosa.ontrack.git.GitRepository in project ontrack by nemerosa.
the class GitRepositoryClientImpl method log.
@Override
public Stream<GitCommit> log(String from, String to) {
try {
Repository gitRepository = git.getRepository();
ObjectId oFrom = gitRepository.resolve(from);
ObjectId oTo = gitRepository.resolve(to);
if (oFrom == null || oTo == null) {
return Collections.<GitCommit>emptyList().stream();
} else {
return Lists.newArrayList(git.log().addRange(oFrom, oTo).call()).stream().map(this::toCommit);
}
} catch (GitAPIException e) {
throw new GitRepositoryAPIException(repository.getRemote(), e);
} catch (IOException e) {
throw new GitRepositoryIOException(repository.getRemote(), e);
}
}
use of net.nemerosa.ontrack.git.GitRepository in project ontrack by nemerosa.
the class GitRepositoryClientImpl method range.
protected GitRange range(String from, String to, boolean reorder) throws IOException {
Repository gitRepository = git.getRepository();
ObjectId oFrom = gitRepository.resolve(from);
ObjectId oTo = gitRepository.resolve(to);
RevWalk walk = new RevWalk(gitRepository);
RevCommit commitFrom = walk.parseCommit(oFrom);
RevCommit commitTo = walk.parseCommit(oTo);
if (reorder && commitFrom.getCommitTime() > commitTo.getCommitTime()) {
RevCommit t = commitFrom;
commitFrom = commitTo;
commitTo = t;
}
return new GitRange(commitFrom, commitTo);
}
Aggregations