This commit is contained in:
Lunny Xiao 2025-01-05 23:17:40 -08:00
parent 91f972ce82
commit 96e050ec63
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A

View File

@ -425,13 +425,18 @@ func GetTreeInformation(ctx context.Context, repo *repo_model.Repository, treePa
}
dir = treePath
if lastDirEntry.IsRegular() {
dir = path.Dir(treePath)
// path.Dir cannot correctly handle .xxx file
dir, _ = path.Split(treePath)
if dir == "" {
lastDirEntry = rootEntry
} else {
lastDirEntry, err = commit.GetTreeEntryByPath(dir)
if err != nil {
return nil, err
}
}
}
}
treeList := make([]*TreeEntry, 0, len(rootEntries))
fields := strings.Split(dir, "/")
@ -448,6 +453,7 @@ func GetTreeInformation(ctx context.Context, repo *repo_model.Repository, treePa
}
}
sortTreeEntries(treeList)
if dir == "" || parentEntry == nil {
return treeList, nil
}
@ -475,7 +481,6 @@ func GetTreeInformation(ctx context.Context, repo *repo_model.Repository, treePa
Path: path.Join(dir, entry.Name()),
})
}
sortTreeEntries(treeList)
sortTreeEntries(parentEntry.Children)
return treeList, nil
}