Skip to content

Commit 4a64b69

Browse files
committed
fix test
1 parent 0677c81 commit 4a64b69

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

modules/git/commit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import (
2020

2121
// Commit represents a git commit.
2222
type Commit struct {
23-
Tree
23+
Tree // FIXME: bad design, this field can be nil if the commit is from "last commit cache"
24+
2425
ID ObjectID // The ID of this commit object
2526
Author *Signature
2627
Committer *Signature

routers/web/repo/view.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,12 @@ func LastCommit(ctx *context.Context) {
254254
ctx.HTML(http.StatusOK, tplRepoViewList)
255255
}
256256

257-
func prepareDirectoryFileIcons(ctx *context.Context, parentDir string, files []git.CommitInfo) {
257+
func prepareDirectoryFileIcons(ctx *context.Context, files []git.CommitInfo) {
258258
renderedIconPool := fileicon.NewRenderedIconPool()
259259
fileIcons := map[string]template.HTML{}
260260
for _, f := range files {
261-
fullPath := path.Join(parentDir, f.Entry.Name())
262-
entryInfo := fileicon.EntryInfoFromGitTreeEntry(f.Commit, fullPath, f.Entry)
261+
fullPath := path.Join(ctx.Repo.TreePath, f.Entry.Name())
262+
entryInfo := fileicon.EntryInfoFromGitTreeEntry(ctx.Repo.Commit, fullPath, f.Entry)
263263
fileIcons[f.Entry.Name()] = fileicon.RenderEntryIconHTML(renderedIconPool, entryInfo)
264264
}
265265
fileIcons[".."] = fileicon.RenderEntryIconHTML(renderedIconPool, fileicon.EntryInfoFolder())
@@ -308,7 +308,7 @@ func renderDirectoryFiles(ctx *context.Context, timeout time.Duration) git.Entri
308308
return nil
309309
}
310310
ctx.Data["Files"] = files
311-
prepareDirectoryFileIcons(ctx, ctx.Repo.TreePath, files)
311+
prepareDirectoryFileIcons(ctx, files)
312312
for _, f := range files {
313313
if f.Commit == nil {
314314
ctx.Data["HasFilesWithoutLatestCommit"] = true

0 commit comments

Comments
 (0)