mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-03 03:55:51 +01:00
Add truncated flag for git
This commit is contained in:
@@ -153,6 +153,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
fileObject.setName("");
|
||||
fileObject.setPath("");
|
||||
fileObject.setDirectory(true);
|
||||
fileObject.setTruncated(false);
|
||||
return fileObject;
|
||||
}
|
||||
|
||||
@@ -253,7 +254,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() + request.getProceedFrom())
|
||||
while (treeWalk.next() && ++resultCount <= request.getLimit() + request.getProceedFrom())
|
||||
{
|
||||
|
||||
FileObject fileObject = createFileObject(repo, request, revId, treeWalk);
|
||||
@@ -262,12 +263,10 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
return fileObject;
|
||||
}
|
||||
|
||||
if (resultCount >= request.getProceedFrom()) {
|
||||
if (resultCount > request.getProceedFrom()) {
|
||||
files.add(fileObject);
|
||||
}
|
||||
|
||||
++resultCount;
|
||||
|
||||
if (request.isRecursive() && fileObject.isDirectory()) {
|
||||
treeWalk.enterSubtree();
|
||||
FileObject rc = findChildren(fileObject, repo, request, revId, treeWalk);
|
||||
@@ -279,6 +278,10 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
|
||||
parent.setChildren(files);
|
||||
|
||||
if (resultCount > request.getLimit() + request.getProceedFrom()) {
|
||||
parent.setTruncated(true);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase {
|
||||
BrowserResult result = createCommand().getBrowserResult(request);
|
||||
FileObject fileObject = result.getFile();
|
||||
assertEquals("a.txt", fileObject.getName());
|
||||
assertFalse(fileObject.isTruncated());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -247,6 +248,7 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase {
|
||||
Collection<FileObject> foList = root.getChildren();
|
||||
|
||||
assertThat(foList).hasSize(2);
|
||||
assertTrue(root.isTruncated());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -261,6 +263,7 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase {
|
||||
Collection<FileObject> foList = root.getChildren();
|
||||
|
||||
assertThat(foList).extracting("name").contains("c", "f.txt");
|
||||
assertFalse(root.isTruncated());
|
||||
}
|
||||
|
||||
private FileObject findFile(Collection<FileObject> foList, String name) {
|
||||
|
||||
Reference in New Issue
Block a user