}
} else {
// git log --all
logCommand.all();
}
Log log = new Log(cloneLocation, db, null /* collected by the job */, pattern, toRefId, fromRefId);
log.setMergeBaseFilter(mergeBaseFilter);
if (messageFilter != null && messageFilter.length() > 0) {
log.setMessagePattern(messageFilter);
logCommand.setMessageFilter(messageFilter);
}
if (authorFilter != null && authorFilter.length() > 0) {
log.setAuthorPattern(authorFilter);
logCommand.setAuthFilter(authorFilter);
}
if (committerFilter != null && committerFilter.length() > 0) {
log.setCommitterPattern(committerFilter);
logCommand.setCommitterFilter(committerFilter);
}
if (sha1Filter != null && sha1Filter.length() > 0) {
log.setSHA1Pattern(sha1Filter);
logCommand.setSHA1Filter(sha1Filter);
}
if (fromDate != null && fromDate.length() > 0) {
log.setFromDate(fromDate);
if (toDate != null && toDate.length() > 0) {
log.setToDate(toDate);
logCommand.setDateFilter(fromDate, toDate);
} else {
logCommand.setDateFilter(fromDate, null);
}
} else if (toDate != null && toDate.length() > 0) {
log.setToDate(toDate);
logCommand.setDateFilter(null, toDate);
}
if (page > 0) {
logCommand.setSkip((page - 1) * pageSize);
logCommand.setMaxCount(pageSize + 1); // to check if next page
// link is needed
}
if (pattern != null && !pattern.isEmpty()) {
logCommand.addPath(pattern);
}
log.setPaging(page, pageSize);
Iterable<RevCommit> commits = logCommand.call();
log.setCommits(commits);
JSONObject result = log.toJSON();
if (mergeBaseFilter) {
result.put(GitConstants.KEY_BEHIND_COUNT, behindCount);
result.put(GitConstants.KEY_AHEAD_COUNT, aheadCount);
}