mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-19 19:18:43 +02:00
Merge pull request #3 from lunny/add-file-tree-to-file-view-page
Fix a TODO
This commit is contained in:
commit
a1830dc1e8
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
|
"code.gitea.io/gitea/modules/gitrepo"
|
||||||
"code.gitea.io/gitea/services/context"
|
"code.gitea.io/gitea/services/context"
|
||||||
files_service "code.gitea.io/gitea/services/repository/files"
|
files_service "code.gitea.io/gitea/services/repository/files"
|
||||||
|
|
||||||
@ -59,10 +60,18 @@ func Tree(ctx *context.Context) {
|
|||||||
ref := ctx.FormTrim("ref")
|
ref := ctx.FormTrim("ref")
|
||||||
recursive := ctx.FormBool("recursive")
|
recursive := ctx.FormBool("recursive")
|
||||||
|
|
||||||
// TODO: Only support branch for now
|
gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, ctx.Repo.Repository)
|
||||||
results, err := files_service.GetTreeList(ctx, ctx.Repo.Repository, dir, git.RefNameFromBranch(ref), recursive)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("guessRefInfoAndDir", err)
|
ctx.ServerError("RepositoryFromContextOrOpen", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer closer.Close()
|
||||||
|
|
||||||
|
refName := gitRepo.UnstableGuessRefByShortName(ref)
|
||||||
|
|
||||||
|
results, err := files_service.GetTreeList(ctx, ctx.Repo.Repository, dir, refName, recursive)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetTreeList", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ func GetTreeList(ctx context.Context, repo *repo_model.Repository, treePath stri
|
|||||||
// Check that the path given in opts.treePath is valid (not a git path)
|
// Check that the path given in opts.treePath is valid (not a git path)
|
||||||
cleanTreePath := CleanUploadFileName(treePath)
|
cleanTreePath := CleanUploadFileName(treePath)
|
||||||
if cleanTreePath == "" && treePath != "" {
|
if cleanTreePath == "" && treePath != "" {
|
||||||
return nil, models.ErrFilenameInvalid{
|
return nil, ErrFilenameInvalid{
|
||||||
Path: treePath,
|
Path: treePath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user