mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-03 03:55:51 +01:00
Implement proceed from for git
This commit is contained in:
@@ -253,7 +253,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
|
||||
private FileObject findChildren(FileObject parent, org.eclipse.jgit.lib.Repository repo, BrowseCommandRequest request, ObjectId revId, TreeWalk treeWalk) throws IOException {
|
||||
List<FileObject> files = Lists.newArrayList();
|
||||
while (treeWalk.next() && resultCount < request.getLimit())
|
||||
while (treeWalk.next() && resultCount < request.getLimit() + request.getProceedFrom())
|
||||
{
|
||||
|
||||
FileObject fileObject = createFileObject(repo, request, revId, treeWalk);
|
||||
@@ -262,7 +262,9 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
return fileObject;
|
||||
}
|
||||
|
||||
files.add(fileObject);
|
||||
if (resultCount >= request.getProceedFrom()) {
|
||||
files.add(fileObject);
|
||||
}
|
||||
|
||||
++resultCount;
|
||||
|
||||
|
||||
@@ -249,6 +249,20 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase {
|
||||
assertThat(foList).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBrowseProceedFrom() throws IOException {
|
||||
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||
request.setLimit(2);
|
||||
request.setProceedFrom(2);
|
||||
FileObject root = createCommand()
|
||||
.getBrowserResult(request).getFile();
|
||||
assertNotNull(root);
|
||||
|
||||
Collection<FileObject> foList = root.getChildren();
|
||||
|
||||
assertThat(foList).extracting("name").contains("c", "f.txt");
|
||||
}
|
||||
|
||||
private FileObject findFile(Collection<FileObject> foList, String name) {
|
||||
return foList.stream()
|
||||
.filter(f -> name.equals(f.getName()))
|
||||
|
||||
Reference in New Issue
Block a user