Skip to content

Commit 743d476

Browse files
committed
fix: add rate limiter
1 parent f8aabf8 commit 743d476

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99

1010
require (
1111
github.com/cli/safeexec v1.0.1 // indirect
12+
github.com/gofri/go-github-ratelimit v1.1.0 // indirect
1213
github.com/google/go-querystring v1.1.0 // indirect
1314
github.com/kr/text v0.2.0 // indirect
1415
github.com/samber/lo v1.47.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ github.com/cli/safeexec v1.0.1/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5
77
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
88
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
99
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
10+
github.com/gofri/go-github-ratelimit v1.1.0 h1:ijQ2bcv5pjZXNil5FiwglCg8wc9s8EgjTmNkqjw8nuk=
11+
github.com/gofri/go-github-ratelimit v1.1.0/go.mod h1:OnCi5gV+hAG/LMR7llGhU7yHt44se9sYgKPnafoL7RY=
1012
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
1113
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
1214
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=

main.go

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

99
"github.com/cli/go-gh/v2/pkg/auth"
1010
"github.com/cli/go-gh/v2/pkg/repository"
11+
"github.com/gofri/go-github-ratelimit/github_ratelimit"
1112
"github.com/google/go-github/v67/github"
1213
"github.com/prefapp/gh-commit/git"
1314
)
@@ -32,7 +33,12 @@ func main() {
3233
host, _ := auth.DefaultHost()
3334
token, _ := auth.TokenForHost(host)
3435

35-
client := github.NewClient(nil).WithAuthToken(token)
36+
rateLimiter, err := github_ratelimit.NewRateLimitWaiterClient(nil)
37+
if err != nil {
38+
panic(err)
39+
}
40+
41+
client := github.NewClient(rateLimiter).WithAuthToken(token)
3642

3743
parsedRepo, err := repository.Parse(*repo)
3844

0 commit comments

Comments
 (0)