@@ -17,7 +17,7 @@ import (
17
17
)
18
18
19
19
// GetCommitsInfo gets information of all commits that are corresponding to these entries
20
- func (tes Entries ) GetCommitsInfo (ctx context.Context , commit * Commit , treePath string , cache * LastCommitCache ) ([]CommitInfo , * Commit , error ) {
20
+ func (tes Entries ) GetCommitsInfo (ctx context.Context , commit * Commit , treePath string ) ([]CommitInfo , * Commit , error ) {
21
21
entryPaths := make ([]string , len (tes )+ 1 )
22
22
// Get the commit for the treePath itself
23
23
entryPaths [0 ] = ""
@@ -35,15 +35,15 @@ func (tes Entries) GetCommitsInfo(ctx context.Context, commit *Commit, treePath
35
35
return nil , nil , err
36
36
}
37
37
38
- var revs map [string ]* object. Commit
39
- if cache != nil {
38
+ var revs map [string ]* Commit
39
+ if commit . repo . LastCommitCache != nil {
40
40
var unHitPaths []string
41
- revs , unHitPaths , err = getLastCommitForPathsByCache (commit .ID .String (), treePath , entryPaths , cache )
41
+ revs , unHitPaths , err = getLastCommitForPathsByCache (commit .ID .String (), treePath , entryPaths , commit . repo . LastCommitCache )
42
42
if err != nil {
43
43
return nil , nil , err
44
44
}
45
45
if len (unHitPaths ) > 0 {
46
- revs2 , err := GetLastCommitForPaths (ctx , cache , c , treePath , unHitPaths )
46
+ revs2 , err := GetLastCommitForPaths (ctx , commit . repo . LastCommitCache , c , treePath , unHitPaths )
47
47
if err != nil {
48
48
return nil , nil , err
49
49
}
@@ -68,8 +68,7 @@ func (tes Entries) GetCommitsInfo(ctx context.Context, commit *Commit, treePath
68
68
}
69
69
70
70
// Check if we have found a commit for this entry in time
71
- if rev , ok := revs [entry .Name ()]; ok {
72
- entryCommit := convertCommit (rev )
71
+ if entryCommit , ok := revs [entry .Name ()]; ok {
73
72
commitsInfo [i ].Commit = entryCommit
74
73
}
75
74
@@ -96,10 +95,10 @@ func (tes Entries) GetCommitsInfo(ctx context.Context, commit *Commit, treePath
96
95
// get it for free during the tree traversal and it's used for listing
97
96
// pages to display information about newest commit for a given path.
98
97
var treeCommit * Commit
98
+ var ok bool
99
99
if treePath == "" {
100
100
treeCommit = commit
101
- } else if rev , ok := revs ["" ]; ok {
102
- treeCommit = convertCommit (rev )
101
+ } else if treeCommit , ok = revs ["" ]; ok {
103
102
treeCommit .repo = commit .repo
104
103
}
105
104
return commitsInfo , treeCommit , nil
@@ -155,16 +154,16 @@ func getFileHashes(c cgobject.CommitNode, treePath string, paths []string) (map[
155
154
return hashes , nil
156
155
}
157
156
158
- func getLastCommitForPathsByCache (commitID , treePath string , paths []string , cache * LastCommitCache ) (map [string ]* object. Commit , []string , error ) {
157
+ func getLastCommitForPathsByCache (commitID , treePath string , paths []string , cache * LastCommitCache ) (map [string ]* Commit , []string , error ) {
159
158
var unHitEntryPaths []string
160
- results := make (map [string ]* object. Commit )
159
+ results := make (map [string ]* Commit )
161
160
for _ , p := range paths {
162
161
lastCommit , err := cache .Get (commitID , path .Join (treePath , p ))
163
162
if err != nil {
164
163
return nil , nil , err
165
164
}
166
165
if lastCommit != nil {
167
- results [p ] = lastCommit .( * object. Commit )
166
+ results [p ] = lastCommit
168
167
continue
169
168
}
170
169
@@ -175,7 +174,7 @@ func getLastCommitForPathsByCache(commitID, treePath string, paths []string, cac
175
174
}
176
175
177
176
// GetLastCommitForPaths returns last commit information
178
- func GetLastCommitForPaths (ctx context.Context , cache * LastCommitCache , c cgobject.CommitNode , treePath string , paths []string ) (map [string ]* object. Commit , error ) {
177
+ func GetLastCommitForPaths (ctx context.Context , cache * LastCommitCache , c cgobject.CommitNode , treePath string , paths []string ) (map [string ]* Commit , error ) {
179
178
refSha := c .ID ().String ()
180
179
181
180
// We do a tree traversal with nodes sorted by commit time
@@ -293,13 +292,13 @@ heaploop:
293
292
}
294
293
295
294
// Post-processing
296
- result := make (map [string ]* object. Commit )
295
+ result := make (map [string ]* Commit )
297
296
for path , commitNode := range resultNodes {
298
- var err error
299
- result [path ], err = commitNode .Commit ()
297
+ commit , err := commitNode .Commit ()
300
298
if err != nil {
301
299
return nil , err
302
300
}
301
+ result [path ] = convertCommit (commit )
303
302
}
304
303
305
304
return result , nil
0 commit comments