private boolean dryRun;
@Override
public void runInternal(GeogigCLI cli) throws IOException {
final ConsoleReader console = cli.getConsole();
final GeoGIG geogig = cli.getGeogig();
String pathFilter = null;
if (!path.isEmpty()) {
pathFilter = path.get(0);
}
if (dryRun) {
if (pathFilter != null) {
// check that is a valid path
Repository repository = cli.getGeogig().getRepository();
NodeRef.checkValidPath(pathFilter);
Optional<NodeRef> ref = repository.command(FindTreeChild.class).setIndex(true)
.setParent(repository.workingTree().getTree()).setChildPath(pathFilter)
.call();
checkParameter(ref.isPresent(), "pathspec '%s' did not match any tree", pathFilter);
checkParameter(ref.get().getType() == TYPE.TREE,
"pathspec '%s' did not resolve to a tree", pathFilter);
}
Iterator<DiffEntry> unstaged = geogig.command(DiffWorkTree.class).setFilter(pathFilter)
.call();
while (unstaged.hasNext()) {
DiffEntry entry = unstaged.next();
if (entry.changeType() == ChangeType.ADDED) {
console.println("Would remove " + entry.newPath());
}
}
} else {
geogig.command(CleanOp.class).setPath(pathFilter).call();
console.println("Clean operation completed succesfully.");
}
}