pgm: Handle GitAPIException in Rm command
This avoids we show a stacktrace on the console by default when this type of exception is thrown during the run method is executed. Change-Id: I55c15a35369e790a3ca946d6db0097a57ac6fae5 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
795c265c11
commit
ed0d6e69f9
|
@ -49,6 +49,7 @@
|
||||||
|
|
||||||
import org.eclipse.jgit.api.Git;
|
import org.eclipse.jgit.api.Git;
|
||||||
import org.eclipse.jgit.api.RmCommand;
|
import org.eclipse.jgit.api.RmCommand;
|
||||||
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
import org.kohsuke.args4j.Argument;
|
import org.kohsuke.args4j.Argument;
|
||||||
import org.kohsuke.args4j.Option;
|
import org.kohsuke.args4j.Option;
|
||||||
import org.kohsuke.args4j.spi.StopOptionHandler;
|
import org.kohsuke.args4j.spi.StopOptionHandler;
|
||||||
|
@ -61,12 +62,14 @@ class Rm extends TextBuiltin {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Exception {
|
protected void run() {
|
||||||
try (Git git = new Git(db)) {
|
try (Git git = new Git(db)) {
|
||||||
RmCommand command = git.rm();
|
RmCommand command = git.rm();
|
||||||
for (String p : paths)
|
for (String p : paths)
|
||||||
command.addFilepattern(p);
|
command.addFilepattern(p);
|
||||||
command.call();
|
command.call();
|
||||||
|
} catch (GitAPIException e) {
|
||||||
|
throw die(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue