mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-06 21:45:43 +01:00
Throw not found exceptions for log between branches
This commit is contained in:
@@ -49,6 +49,7 @@ import org.eclipse.jgit.treewalk.filter.PathFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.NotFoundException;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.GitChangesetConverter;
|
||||
@@ -206,6 +207,9 @@ 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));
|
||||
}
|
||||
}
|
||||
|
||||
revWalk = new RevWalk(repository);
|
||||
@@ -245,6 +249,8 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (ancestorId != null) {
|
||||
throw notFound(entity("Revision", request.getBranch()).in(this.repository));
|
||||
}
|
||||
|
||||
if (branch != null) {
|
||||
@@ -263,6 +269,10 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
{
|
||||
throw notFound(entity("Revision", e.getObjectId().getName()).in(repository));
|
||||
}
|
||||
catch (NotFoundException e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InternalRepositoryException(repository, "could not create change log", ex);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import org.junit.Test;
|
||||
import sonia.scm.NotFoundException;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -95,6 +96,28 @@ public class GitLogCommandAncestorTest extends AbstractGitCommandTestBase
|
||||
assertEquals("201ecc1131e6b99fb0a0fe9dcbc8c044383e1a07", result.getChangesets().get(6).getId());
|
||||
}
|
||||
|
||||
@Test(expected = NotFoundException.class)
|
||||
public void testAncestorWithDeletedSourceBranch()
|
||||
{
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
request.setBranch("no_such_branch");
|
||||
request.setAncestorChangeset("master");
|
||||
|
||||
createCommand().getChangesets(request);
|
||||
}
|
||||
|
||||
@Test(expected = NotFoundException.class)
|
||||
public void testAncestorWithDeletedAncestorBranch()
|
||||
{
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
request.setBranch("b");
|
||||
request.setAncestorChangeset("no_such_branch");
|
||||
|
||||
createCommand().getChangesets(request);
|
||||
}
|
||||
|
||||
private GitLogCommand createCommand()
|
||||
{
|
||||
return new GitLogCommand(createContext(), repository);
|
||||
|
||||
Reference in New Issue
Block a user