0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-18 17:22:56 +02:00
This commit is contained in:
Lunny Xiao 2025-01-06 00:28:21 -08:00
parent a125a58e81
commit 87ed579357
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 8 additions and 6 deletions

View File

@ -427,6 +427,7 @@ func GetTreeInformation(ctx context.Context, repo *repo_model.Repository, treePa
if lastDirEntry.IsRegular() {
// path.Dir cannot correctly handle .xxx file
dir, _ = path.Split(treePath)
dir = strings.TrimRight(dir, "/")
if dir == "" {
lastDirEntry = rootEntry
} else {

View File

@ -139,14 +139,15 @@ func Test_GetTreeInformation(t *testing.T) {
treeList, err = GetTreeInformation(ctx2, ctx2.Repo.Repository, "", refName)
assert.NoError(t, err)
assert.Len(t, treeList, 2)
assert.EqualValues(t, "README.md", treeList[0].Name)
assert.EqualValues(t, "README.md", treeList[0].Path)
assert.True(t, treeList[0].IsFile)
assert.EqualValues(t, "doc", treeList[0].Name)
assert.EqualValues(t, "doc", treeList[0].Path)
assert.False(t, treeList[0].IsFile)
assert.Empty(t, treeList[0].Children)
assert.EqualValues(t, "doc", treeList[1].Name)
assert.EqualValues(t, "doc", treeList[1].Path)
assert.False(t, treeList[1].IsFile)
assert.EqualValues(t, "README.md", treeList[1].Name)
assert.EqualValues(t, "README.md", treeList[1].Path)
assert.True(t, treeList[1].IsFile)
assert.Empty(t, treeList[1].Children)
treeList, err = GetTreeInformation(ctx2, ctx2.Repo.Repository, "doc", refName)