use of org.eclipse.jgit.api.LogCommand 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);
}
}
}
use of org.eclipse.jgit.api.LogCommand in project Gargoyle by callakrsos.
the class GitTest method history.
@Test
public void history() throws IOException, NoHeadException, GitAPIException {
Git open = Git.open(new File("C:\\Users\\KYJ\\.git\\Gargoyle"));
LogCommand log = open.log();
log.call().forEach(coit -> {
ObjectId id = coit.getId();
String idName = id.getName();
String fullMessage = coit.getFullMessage();
String name = coit.getCommitterIdent().getName();
Date when = coit.getCommitterIdent().getWhen();
String date = DateUtil.toString(when, DateUtil.SYSTEM_DATEFORMAT_YYYY_MM_DD_HH_MM_SS);
System.out.printf("%s \t\t %s \t\t %s\t\t %s\n", idName, date, name, fullMessage);
});
}
use of org.eclipse.jgit.api.LogCommand in project che by eclipse.
the class JGitConnection method getCommiters.
@Override
public List<GitUser> getCommiters() throws GitException {
List<GitUser> gitUsers = new ArrayList<>();
try {
LogCommand logCommand = getGit().log();
for (RevCommit commit : logCommand.call()) {
PersonIdent committerIdentity = commit.getCommitterIdent();
GitUser gitUser = newDto(GitUser.class).withName(committerIdentity.getName()).withEmail(committerIdentity.getEmailAddress());
if (!gitUsers.contains(gitUser)) {
gitUsers.add(gitUser);
}
}
} catch (GitAPIException exception) {
throw new GitException(exception.getMessage(), exception);
}
return gitUsers;
}
Aggregations