pgm: Handle exceptions in LsRemote 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: If7dd168f3e8d2b729f1eab48d4e95fe837bb7a33 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
1978f180a2
commit
40562d7f5c
|
@ -51,6 +51,7 @@
|
||||||
|
|
||||||
import org.eclipse.jgit.api.Git;
|
import org.eclipse.jgit.api.Git;
|
||||||
import org.eclipse.jgit.api.LsRemoteCommand;
|
import org.eclipse.jgit.api.LsRemoteCommand;
|
||||||
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
import org.eclipse.jgit.lib.AnyObjectId;
|
import org.eclipse.jgit.lib.AnyObjectId;
|
||||||
import org.eclipse.jgit.lib.Ref;
|
import org.eclipse.jgit.lib.Ref;
|
||||||
import org.kohsuke.args4j.Argument;
|
import org.kohsuke.args4j.Argument;
|
||||||
|
@ -72,7 +73,7 @@ class LsRemote extends TextBuiltin {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Exception {
|
protected void run() {
|
||||||
LsRemoteCommand command = Git.lsRemoteRepository().setRemote(remote)
|
LsRemoteCommand command = Git.lsRemoteRepository().setRemote(remote)
|
||||||
.setTimeout(timeout).setHeads(heads).setTags(tags);
|
.setTimeout(timeout).setHeads(heads).setTags(tags);
|
||||||
TreeSet<Ref> refs = new TreeSet<>(new Comparator<Ref>() {
|
TreeSet<Ref> refs = new TreeSet<>(new Comparator<Ref>() {
|
||||||
|
@ -82,11 +83,15 @@ public int compare(Ref r1, Ref r2) {
|
||||||
return r1.getName().compareTo(r2.getName());
|
return r1.getName().compareTo(r2.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
refs.addAll(command.call());
|
try {
|
||||||
for (Ref r : refs) {
|
refs.addAll(command.call());
|
||||||
show(r.getObjectId(), r.getName());
|
for (Ref r : refs) {
|
||||||
if (r.getPeeledObjectId() != null)
|
show(r.getObjectId(), r.getName());
|
||||||
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
|
if (r.getPeeledObjectId() != null)
|
||||||
|
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
} catch (GitAPIException | IOException e) {
|
||||||
|
throw die(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue