Skip to content

Commit

Permalink
Merge pull request #3 from lunny/add-file-tree-to-file-view-page
Browse files Browse the repository at this point in the history
Fix a TODO
  • Loading branch information
kerwin612 authored Dec 24, 2024
2 parents 6cb22e5 + f2b1da5 commit a1830dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions routers/web/repo/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion services/repository/files/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down

0 comments on commit a1830dc

Please sign in to comment.