@@ -17,7 +17,7 @@ import (
1717)
1818
1919// 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 ) {
2121 entryPaths := make ([]string , len (tes )+ 1 )
2222 // Get the commit for the treePath itself
2323 entryPaths [0 ] = ""
@@ -35,15 +35,15 @@ func (tes Entries) GetCommitsInfo(ctx context.Context, commit *Commit, treePath
3535 return nil , nil , err
3636 }
3737
38- var revs map [string ]* object. Commit
39- if cache != nil {
38+ var revs map [string ]* Commit
39+ if commit . repo . LastCommitCache != nil {
4040 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 )
4242 if err != nil {
4343 return nil , nil , err
4444 }
4545 if len (unHitPaths ) > 0 {
46- revs2 , err := GetLastCommitForPaths (ctx , cache , c , treePath , unHitPaths )
46+ revs2 , err := GetLastCommitForPaths (ctx , commit . repo . LastCommitCache , c , treePath , unHitPaths )
4747 if err != nil {
4848 return nil , nil , err
4949 }
@@ -68,8 +68,7 @@ func (tes Entries) GetCommitsInfo(ctx context.Context, commit *Commit, treePath
6868 }
6969
7070 // 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 {
7372 commitsInfo [i ].Commit = entryCommit
7473 }
7574
@@ -96,10 +95,10 @@ func (tes Entries) GetCommitsInfo(ctx context.Context, commit *Commit, treePath
9695 // get it for free during the tree traversal and it's used for listing
9796 // pages to display information about newest commit for a given path.
9897 var treeCommit * Commit
98+ var ok bool
9999 if treePath == "" {
100100 treeCommit = commit
101- } else if rev , ok := revs ["" ]; ok {
102- treeCommit = convertCommit (rev )
101+ } else if treeCommit , ok = revs ["" ]; ok {
103102 treeCommit .repo = commit .repo
104103 }
105104 return commitsInfo , treeCommit , nil
@@ -155,16 +154,16 @@ func getFileHashes(c cgobject.CommitNode, treePath string, paths []string) (map[
155154 return hashes , nil
156155}
157156
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 ) {
159158 var unHitEntryPaths []string
160- results := make (map [string ]* object. Commit )
159+ results := make (map [string ]* Commit )
161160 for _ , p := range paths {
162161 lastCommit , err := cache .Get (commitID , path .Join (treePath , p ))
163162 if err != nil {
164163 return nil , nil , err
165164 }
166165 if lastCommit != nil {
167- results [p ] = lastCommit .( * object. Commit )
166+ results [p ] = lastCommit
168167 continue
169168 }
170169
@@ -175,7 +174,7 @@ func getLastCommitForPathsByCache(commitID, treePath string, paths []string, cac
175174}
176175
177176// 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 ) {
179178 refSha := c .ID ().String ()
180179
181180 // We do a tree traversal with nodes sorted by commit time
@@ -293,13 +292,13 @@ heaploop:
293292 }
294293
295294 // Post-processing
296- result := make (map [string ]* object. Commit )
295+ result := make (map [string ]* Commit )
297296 for path , commitNode := range resultNodes {
298- var err error
299- result [path ], err = commitNode .Commit ()
297+ commit , err := commitNode .Commit ()
300298 if err != nil {
301299 return nil , err
302300 }
301+ result [path ] = convertCommit (commit )
303302 }
304303
305304 return result , nil
0 commit comments