Skip to content

Commit

Permalink
fix(github): Infinite loop when fetching tags
Browse files Browse the repository at this point in the history
  • Loading branch information
ViBiOh committed May 23, 2020
1 parent 02c3b85 commit 04e0b9c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (a app) parseTags(repository string) (semver.Version, error) {
}
}

if !isLastPage(resp) {
if !hasNext(resp) {
break
}

Expand All @@ -105,6 +105,12 @@ func (a app) parseTags(repository string) (semver.Version, error) {
return version, nil
}

func isLastPage(resp *http.Response) bool {
return !strings.Contains(resp.Header.Get("Link"), `rel="next"`)
func hasNext(resp *http.Response) bool {
for _, value := range resp.Header.Values("Link") {
if strings.Contains(value, `rel="next"`) {
return true
}
}

return false
}

0 comments on commit 04e0b9c

Please sign in to comment.