1
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-01-19 14:03:40 +03:00
This commit is contained in:
Lunny Xiao 2024-12-23 22:08:53 -08:00
parent a86c9e43a9
commit 3b3eaec840
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A

View File

@ -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
}