fix there is no error on missing revision

This commit is contained in:
Mohamed Karray
2019-03-11 18:42:10 +01:00
parent 856f564c8d
commit 77fb869ce4
3 changed files with 17 additions and 5 deletions

View File

@@ -65,6 +65,9 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import static sonia.scm.ContextEntry.ContextBuilder.entity;
import static sonia.scm.NotFoundException.notFound;
//~--- JDK imports ------------------------------------------------------------
/**
@@ -128,10 +131,11 @@ public class GitBrowseCommand extends AbstractGitCommand
if (Util.isNotEmpty(request.getRevision()))
{
logger.error("could not find revision {}", request.getRevision());
throw notFound(entity("Revision", request.getRevision()).in(this.repository));
}
else if (logger.isWarnEnabled())
{
logger.warn("coul not find head of repository, empty?");
logger.warn("could not find head of repository, empty?");
}
result = new BrowserResult(Constants.HEAD, createEmtpyRoot());

View File

@@ -79,6 +79,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
*/
private static final Logger logger =
LoggerFactory.getLogger(GitLogCommand.class);
public static final String REVISION = "Revision";
//~--- constructors ---------------------------------------------------------
@@ -143,6 +144,10 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
{
logger.error("could not open repository", ex);
}
catch (NullPointerException e)
{
throw notFound(entity(REVISION, revision).in(this.repository));
}
finally
{
IOUtil.close(converter);
@@ -208,7 +213,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
if (!Strings.isNullOrEmpty(request.getAncestorChangeset())) {
ancestorId = repository.resolve(request.getAncestorChangeset());
if (ancestorId == null) {
throw notFound(entity("Revision", request.getAncestorChangeset()).in(this.repository));
throw notFound(entity(REVISION, request.getAncestorChangeset()).in(this.repository));
}
}
@@ -250,7 +255,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
}
}
} else if (ancestorId != null) {
throw notFound(entity("Revision", request.getBranch()).in(this.repository));
throw notFound(entity(REVISION, request.getBranch()).in(this.repository));
}
if (branch != null) {
@@ -267,7 +272,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
}
catch (MissingObjectException e)
{
throw notFound(entity("Revision", e.getObjectId().getName()).in(repository));
throw notFound(entity(REVISION, e.getObjectId().getName()).in(repository));
}
catch (NotFoundException e)
{