ConsoleReader console = cli.getConsole();
console.print("Committing changeset " + changeset.getId() + "...");
console.flush();
GeoGIG geogig = cli.getGeogig();
CommitOp command = geogig.command(CommitOp.class);
command.setAllowEmpty(true);
String message = "";
if (changeset.getComment().isPresent()) {
message = changeset.getComment().get() + "\nchangeset " + changeset.getId();
} else {
message = "changeset " + changeset.getId();
}
command.setMessage(message);
final String userName = changeset.getUserName();
command.setAuthor(userName, null);
command.setAuthorTimestamp(changeset.getCreated());
command.setAuthorTimeZoneOffset(0);// osm timestamps are in GMT
if (userName != null) {
command.setCommitter(userName, null);
}
command.setCommitterTimestamp(changeset.getClosed().get());
command.setCommitterTimeZoneOffset(0);// osm timestamps are in GMT
ProgressListener listener = cli.getProgressListener();
listener.setProgress(0f);
listener.started();
command.setProgressListener(listener);
try {
RevCommit commit = command.call();
Ref head = geogig.command(RefParse.class).setName(Ref.HEAD).call().get();
Preconditions.checkState(commit.getId().equals(head.getObjectId()));
updateBranchChangeset(geogig, changeset.getId());
listener.complete();
console.println("Commit " + commit.getId().toString());