@@ -6,7 +6,6 @@ package repository
6
6
import (
7
7
"bufio"
8
8
"context"
9
- "errors"
10
9
"fmt"
11
10
"os"
12
11
"strconv"
@@ -29,8 +28,6 @@ const (
29
28
contributorStatsCacheTimeout int64 = 60 * 10
30
29
)
31
30
32
- var ErrAwaitGeneration = errors .New ("generation took longer than " )
33
-
34
31
type WeekData struct {
35
32
Week int64 `json:"week"` // Starting day of the week as Unix timestamp
36
33
Additions int `json:"additions"` // Number of additions in that week
@@ -85,14 +82,14 @@ func GetContributorStats(ctx context.Context, cache cache.StringCache, repo *rep
85
82
return res , nil
86
83
}
87
84
88
- // dont start multiple async generations
85
+ // dont start multiple generations for the same repository and same revision
89
86
releaser , err := globallock .Lock (ctx , cacheKey )
90
87
if err != nil {
91
88
return nil , err
92
89
}
93
90
defer releaser ()
94
91
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
96
93
if cache .IsExist (cacheKey ) {
97
94
var res map [string ]* ContributorData
98
95
if _ , cacheErr := cache .GetJSON (cacheKey , & res ); cacheErr != nil {
@@ -101,7 +98,6 @@ func GetContributorStats(ctx context.Context, cache cache.StringCache, repo *rep
101
98
return res , nil
102
99
}
103
100
104
- // run generation async
105
101
res , err := generateContributorStats (ctx , repo , revision )
106
102
if err != nil {
107
103
return nil , err
@@ -196,7 +192,7 @@ func getExtendedCommitStats(ctx context.Context, repoPath string, baseCommit *gi
196
192
},
197
193
})
198
194
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 )
200
196
}
201
197
202
198
return extendedCommitStats , nil
0 commit comments