1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-07-05 00:59:04 +02:00

fix(github): check rate limit again after sleeping (#4152)

also ensure sleep > 0

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker
2023-06-29 14:00:23 -03:00
committed by GitHub
parent e9760a167b
commit f883131e73
2 changed files with 17 additions and 0 deletions

View File

@ -75,8 +75,15 @@ func (c *githubClient) checkRateLimit(ctx *context.Context) {
return
}
sleep := limits.Core.Reset.UTC().Sub(time.Now().UTC())
if sleep <= 0 {
// it seems that sometimes, after the rate limit just reset, it might
// still get <100 remaining and a reset time in the past... in such
// cases we can probably sleep a bit more before trying again...
sleep = 15 * time.Second
}
log.Warnf("token too close to rate limiting, will sleep for %s before continuing...", sleep)
time.Sleep(sleep)
c.checkRateLimit(ctx)
}
func (c *githubClient) GenerateReleaseNotes(ctx *context.Context, repo Repo, prev, current string) (string, error) {