use of org.locationtech.geogig.api.porcelain.ResetOp in project GeoGig by boundlessgeo.
the class Reset method runInternal.
/**
* Executes the reset command using the provided options.
*
* @param cli
* @see org.locationtech.geogig.cli.AbstractCommand#runInternal(org.locationtech.geogig.cli.GeogigCLI)
*/
@Override
public void runInternal(GeogigCLI cli) {
final GeoGIG geogig = cli.getGeogig();
ResetMode mode = resolveResetMode();
ResetOp reset = cli.getGeogig().command(ResetOp.class);
try {
for (int i = 0; args != null && i < args.size(); i++) {
reset.addPattern(args.get(i));
}
if (commit != null && commit.size() > 0) {
Optional<ObjectId> commitId = geogig.command(RevParse.class).setRefSpec(commit.get(0)).call();
checkParameter(commitId.isPresent(), "Commit could not be resolved.");
reset.setCommit(Suppliers.ofInstance(commitId.get()));
}
reset.setMode(mode);
reset.call();
} catch (IllegalArgumentException iae) {
throw new CommandFailedException(iae.getMessage(), iae);
} catch (IllegalStateException ise) {
throw new CommandFailedException(ise.getMessage(), ise);
}
if (!geogig.getRepository().workingTree().isClean()) {
try {
Iterator<DiffEntry> unstaged = geogig.command(DiffWorkTree.class).setFilter(null).call();
cli.getConsole().println("Unstaged changes after reset:");
while (unstaged.hasNext()) {
DiffEntry entry = unstaged.next();
ChangeType type = entry.changeType();
switch(type) {
case ADDED:
cli.getConsole().println("A\t" + entry.newPath());
break;
case MODIFIED:
cli.getConsole().println("M\t" + entry.newPath());
break;
case REMOVED:
cli.getConsole().println("D\t" + entry.oldPath());
break;
}
}
} catch (IOException e) {
}
}
}
Aggregations