@@ -6,7 +6,6 @@ package repository
66import (
77 "bufio"
88 "context"
9- "errors"
109 "fmt"
1110 "os"
1211 "strconv"
@@ -29,8 +28,6 @@ const (
2928 contributorStatsCacheTimeout int64 = 60 * 10
3029)
3130
32- var ErrAwaitGeneration = errors .New ("generation took longer than " )
33-
3431type WeekData struct {
3532 Week int64 `json:"week"` // Starting day of the week as Unix timestamp
3633 Additions int `json:"additions"` // Number of additions in that week
@@ -85,14 +82,14 @@ func GetContributorStats(ctx context.Context, cache cache.StringCache, repo *rep
8582 return res , nil
8683 }
8784
88- // dont start multiple async generations
85+ // dont start multiple generations for the same repository and same revision
8986 releaser , err := globallock .Lock (ctx , cacheKey )
9087 if err != nil {
9188 return nil , err
9289 }
9390 defer releaser ()
9491
95- // check if generation is already completed by other request
92+ // check if generation is already completed by other request when we were waiting for lock
9693 if cache .IsExist (cacheKey ) {
9794 var res map [string ]* ContributorData
9895 if _ , cacheErr := cache .GetJSON (cacheKey , & res ); cacheErr != nil {
@@ -101,7 +98,6 @@ func GetContributorStats(ctx context.Context, cache cache.StringCache, repo *rep
10198 return res , nil
10299 }
103100
104- // run generation async
105101 res , err := generateContributorStats (ctx , repo , revision )
106102 if err != nil {
107103 return nil , err
@@ -196,7 +192,7 @@ func getExtendedCommitStats(ctx context.Context, repoPath string, baseCommit *gi
196192 },
197193 })
198194 if err != nil {
199- return nil , fmt .Errorf ("Failed to get ContributorsCommitStats for repository.\n Error: %w\n Stderr: %s" , err , stderr )
195+ return nil , fmt .Errorf ("failed to get ContributorsCommitStats for repository.\n Error: %w\n Stderr: %s" , err , stderr )
200196 }
201197
202198 return extendedCommitStats , nil
0 commit comments