mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
fix there is no error on missing revision
This commit is contained in:
@@ -65,6 +65,9 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||||
|
import static sonia.scm.NotFoundException.notFound;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,10 +131,11 @@ public class GitBrowseCommand extends AbstractGitCommand
|
|||||||
if (Util.isNotEmpty(request.getRevision()))
|
if (Util.isNotEmpty(request.getRevision()))
|
||||||
{
|
{
|
||||||
logger.error("could not find revision {}", request.getRevision());
|
logger.error("could not find revision {}", request.getRevision());
|
||||||
|
throw notFound(entity("Revision", request.getRevision()).in(this.repository));
|
||||||
}
|
}
|
||||||
else if (logger.isWarnEnabled())
|
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());
|
result = new BrowserResult(Constants.HEAD, createEmtpyRoot());
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
|||||||
*/
|
*/
|
||||||
private static final Logger logger =
|
private static final Logger logger =
|
||||||
LoggerFactory.getLogger(GitLogCommand.class);
|
LoggerFactory.getLogger(GitLogCommand.class);
|
||||||
|
public static final String REVISION = "Revision";
|
||||||
|
|
||||||
//~--- constructors ---------------------------------------------------------
|
//~--- constructors ---------------------------------------------------------
|
||||||
|
|
||||||
@@ -143,6 +144,10 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
|||||||
{
|
{
|
||||||
logger.error("could not open repository", ex);
|
logger.error("could not open repository", ex);
|
||||||
}
|
}
|
||||||
|
catch (NullPointerException e)
|
||||||
|
{
|
||||||
|
throw notFound(entity(REVISION, revision).in(this.repository));
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IOUtil.close(converter);
|
IOUtil.close(converter);
|
||||||
@@ -208,7 +213,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
|||||||
if (!Strings.isNullOrEmpty(request.getAncestorChangeset())) {
|
if (!Strings.isNullOrEmpty(request.getAncestorChangeset())) {
|
||||||
ancestorId = repository.resolve(request.getAncestorChangeset());
|
ancestorId = repository.resolve(request.getAncestorChangeset());
|
||||||
if (ancestorId == null) {
|
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) {
|
} 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) {
|
if (branch != null) {
|
||||||
@@ -267,7 +272,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
|||||||
}
|
}
|
||||||
catch (MissingObjectException e)
|
catch (MissingObjectException e)
|
||||||
{
|
{
|
||||||
throw notFound(entity("Revision", e.getObjectId().getName()).in(repository));
|
throw notFound(entity(REVISION, e.getObjectId().getName()).in(repository));
|
||||||
}
|
}
|
||||||
catch (NotFoundException e)
|
catch (NotFoundException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import javax.ws.rs.Produces;
|
|||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||||
|
import static sonia.scm.NotFoundException.notFound;
|
||||||
|
|
||||||
public class SourceRootResource {
|
public class SourceRootResource {
|
||||||
|
|
||||||
private final RepositoryServiceFactory serviceFactory;
|
private final RepositoryServiceFactory serviceFactory;
|
||||||
@@ -62,7 +65,7 @@ public class SourceRootResource {
|
|||||||
if (browserResult != null) {
|
if (browserResult != null) {
|
||||||
return Response.ok(browserResultToFileObjectDtoMapper.map(browserResult, namespaceAndName)).build();
|
return Response.ok(browserResultToFileObjectDtoMapper.map(browserResult, namespaceAndName)).build();
|
||||||
} else {
|
} else {
|
||||||
return Response.status(Response.Status.NOT_FOUND).build();
|
throw notFound(entity("sources", path).in(namespaceAndName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user