Merge pull request #3 from lunny/add-file-tree-to-file-view-page

Fix a TODO
pull/32721/head
Kerwin Bryant 2 months ago committed by GitHub
commit a1830dc1e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -8,6 +8,7 @@ import (
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/gitrepo"
"code.gitea.io/gitea/services/context"
files_service "code.gitea.io/gitea/services/repository/files"
@ -59,10 +60,18 @@ func Tree(ctx *context.Context) {
ref := ctx.FormTrim("ref")
recursive := ctx.FormBool("recursive")
// TODO: Only support branch for now
results, err := files_service.GetTreeList(ctx, ctx.Repo.Repository, dir, git.RefNameFromBranch(ref), recursive)
gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, ctx.Repo.Repository)
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
}

@ -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)
cleanTreePath := CleanUploadFileName(treePath)
if cleanTreePath == "" && treePath != "" {
return nil, models.ErrFilenameInvalid{
return nil, ErrFilenameInvalid{
Path: treePath,
}
}

Loading…
Cancel
Save