mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-06 13:35:44 +01:00
Detect browse command for root dir correctly in git
This commit is contained in:
@@ -286,7 +286,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
logger.debug("load repository browser for revision {}", revId.name());
|
||||
|
||||
treeWalk = new TreeWalk(repo);
|
||||
if (!Strings.isNullOrEmpty(request.getPath()) && !"/".equals(request.getPath())) {
|
||||
if (!isRootRequest(request)) {
|
||||
treeWalk.setFilter(PathFilter.create(request.getPath()));
|
||||
}
|
||||
revWalk = new RevWalk(repo);
|
||||
@@ -303,7 +303,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
logger.error("could not find tree for {}", revId.name());
|
||||
}
|
||||
|
||||
if (Strings.isNullOrEmpty(request.getPath())) {
|
||||
if (isRootRequest(request)) {
|
||||
result = createEmtpyRoot();
|
||||
findChildren(result, repo, request, revId, treeWalk);
|
||||
} else {
|
||||
@@ -324,6 +324,10 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isRootRequest(BrowseCommandRequest request) {
|
||||
return Strings.isNullOrEmpty(request.getPath()) || "/".equals(request.getPath());
|
||||
}
|
||||
|
||||
private FileObject findChildren(FileObject parent, org.eclipse.jgit.lib.Repository repo, BrowseCommandRequest request, ObjectId revId, TreeWalk treeWalk) throws IOException, RevisionNotFoundException {
|
||||
List<FileObject> files = Lists.newArrayList();
|
||||
while (treeWalk.next())
|
||||
|
||||
Reference in New Issue
Block a user