this.detail = detail;
}
@Override
public void print(RevCommit commit) throws IOException {
Ansi ansi = newAnsi(console.getTerminal());
ansi.a("Commit: ").fg(Color.YELLOW).a(getIdAsString(commit.getId())).reset().newline();
if (commit.getParentIds().size() > 1) {
ansi.a("Merge: ");
for (ObjectId parent : commit.getParentIds()) {
ansi.a(parent.toString().substring(0, 7)).a(" ");
}
ansi.newline();
}
ansi.a("Author: ").fg(Color.GREEN).a(formatPerson(commit.getAuthor())).reset()
.newline();
final long timestamp = commit.getAuthor().getTimestamp();
int timeZoneOffset = commit.getAuthor().getTimeZoneOffset();
if (args.utcDateFormat) {
timeZoneOffset = 0;
}
String friendlyString = estimateSince(now, timestamp);
DATE_FORMAT.getCalendar().getTimeZone().setRawOffset(timeZoneOffset);
String formattedDate = DATE_FORMAT.format(timestamp);
ansi.a("Date: (").fg(Color.RED).a(friendlyString).reset().a(") ").a(formattedDate)
.newline();
ansi.a("Subject: ").a(commit.getMessage()).newline();
if ((detail.equals(LOG_DETAIL.NAMES_ONLY)) && commit.getParentIds().size() == 1) {
ansi.a("Affected paths:").newline();
Iterator<DiffEntry> diff = geogig.command(DiffOp.class)
.setOldVersion(commit.parentN(0).get()).setNewVersion(commit.getId())
.call();
DiffEntry diffEntry;
while (diff.hasNext()) {
diffEntry = diff.next();
ansi.a("\t" + diffEntry.newPath()).newline();
}
}
if (detail.equals(LOG_DETAIL.STATS) && commit.getParentIds().size() == 1) {
Iterator<DiffEntry> diff = geogig.command(DiffOp.class)
.setOldVersion(commit.parentN(0).get()).setNewVersion(commit.getId())
.call();
int adds = 0, deletes = 0, changes = 0;
DiffEntry diffEntry;
while (diff.hasNext()) {
diffEntry = diff.next();
switch (diffEntry.changeType()) {
case ADDED:
++adds;
break;
case REMOVED:
++deletes;
break;
case MODIFIED:
++changes;
break;
}
}
ansi.a("Changes:");
ansi.fg(Color.GREEN).a(adds).reset().a(" features added, ").fg(Color.YELLOW)
.a(changes).reset().a(" changed, ").fg(Color.RED).a(deletes).reset()
.a(" deleted.").reset().newline();
}
console.println(ansi.toString());
if (detail.equals(LOG_DETAIL.SUMMARY) && commit.getParentIds().size() == 1) {
ansi.a("Changes:").newline();
Iterator<DiffEntry> diff = geogig.command(DiffOp.class)
.setOldVersion(commit.parentN(0).get()).setNewVersion(commit.getId())
.call();
DiffEntry diffEntry;
while (diff.hasNext()) {