use of org.eclipse.che.api.git.LogPage in project che by eclipse.
the class JGitConnection method log.
/** @see org.eclipse.che.api.git.GitConnection#log(LogParams) */
@Override
public LogPage log(LogParams params) throws GitException {
LogCommand logCommand = getGit().log();
try {
setRevisionRange(logCommand, params);
logCommand.setSkip(params.getSkip());
logCommand.setMaxCount(params.getMaxCount());
List<String> fileFilter = params.getFileFilter();
if (fileFilter != null) {
fileFilter.forEach(logCommand::addPath);
}
String filePath = params.getFilePath();
if (!isNullOrEmpty(filePath)) {
logCommand.addPath(filePath);
}
Iterator<RevCommit> revIterator = logCommand.call().iterator();
List<Revision> commits = new ArrayList<>();
while (revIterator.hasNext()) {
RevCommit commit = revIterator.next();
Revision revision = getRevision(commit, filePath);
commits.add(revision);
}
return new LogPage(commits);
} catch (GitAPIException | IOException exception) {
String errorMessage = exception.getMessage();
if (ERROR_LOG_NO_HEAD_EXISTS.equals(errorMessage)) {
throw new GitException(errorMessage, ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED);
} else {
LOG.error("Failed to retrieve log. ", exception);
throw new GitException(exception);
}
}
}
Aggregations