mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 05:55: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());
|
logger.debug("load repository browser for revision {}", revId.name());
|
||||||
|
|
||||||
treeWalk = new TreeWalk(repo);
|
treeWalk = new TreeWalk(repo);
|
||||||
if (!Strings.isNullOrEmpty(request.getPath()) && !"/".equals(request.getPath())) {
|
if (!isRootRequest(request)) {
|
||||||
treeWalk.setFilter(PathFilter.create(request.getPath()));
|
treeWalk.setFilter(PathFilter.create(request.getPath()));
|
||||||
}
|
}
|
||||||
revWalk = new RevWalk(repo);
|
revWalk = new RevWalk(repo);
|
||||||
@@ -303,7 +303,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
|||||||
logger.error("could not find tree for {}", revId.name());
|
logger.error("could not find tree for {}", revId.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Strings.isNullOrEmpty(request.getPath())) {
|
if (isRootRequest(request)) {
|
||||||
result = createEmtpyRoot();
|
result = createEmtpyRoot();
|
||||||
findChildren(result, repo, request, revId, treeWalk);
|
findChildren(result, repo, request, revId, treeWalk);
|
||||||
} else {
|
} else {
|
||||||
@@ -324,6 +324,10 @@ public class GitBrowseCommand extends AbstractGitCommand
|
|||||||
return result;
|
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 {
|
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();
|
List<FileObject> files = Lists.newArrayList();
|
||||||
while (treeWalk.next())
|
while (treeWalk.next())
|
||||||
|
|||||||
Reference in New Issue
Block a user