Create and handle RevisionNotFoundException

This commit is contained in:
René Pfeuffer
2018-08-16 10:24:47 +02:00
parent 70039ad540
commit 9babeecea6
4 changed files with 36 additions and 2 deletions

View File

@@ -32,6 +32,7 @@
package sonia.scm.repository.spi;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
@@ -46,6 +47,7 @@ import org.slf4j.LoggerFactory;
import sonia.scm.repository.GitUtil;
import sonia.scm.repository.PathNotFoundException;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.RevisionNotFoundException;
import sonia.scm.util.Util;
import java.io.Closeable;
@@ -97,7 +99,12 @@ public class GitCatCommand extends AbstractGitCommand implements CatCommand {
RevWalk revWalk = new RevWalk(repo);
RevCommit entry = revWalk.parseCommit(revId);
RevCommit entry = null;
try {
entry = revWalk.parseCommit(revId);
} catch (MissingObjectException e) {
throw new RevisionNotFoundException(revId.getName());
}
RevTree revTree = entry.getTree();
if (revTree != null) {