diff --git a/github-release.py b/github-release.py index 59d79c5..cebf23f 100755 --- a/github-release.py +++ b/github-release.py @@ -8,7 +8,7 @@ from datetime import datetime import tempfile import json - +import re import requests @@ -203,9 +203,21 @@ def link_latest(name, repo_dir): print(f"syncing {repo} to {repo_dir}") try: - r = github_get(f"{args.base_url}{repo}/releases") - r.raise_for_status() - releases = r.json() + headers = {"Accept": "application/vnd.github+json"} + releases = [] + url_str = f"{args.base_url}{repo}/releases" + pattern = re.compile(r'.*<(.*?)>;\s*rel="next"') + while url_str: + r = github_get(url_str, headers=headers) + r.raise_for_status() + releases.extend(r.json()) + next_url = re.findall(pattern=pattern,string=r.headers["link"]) + if versions > 0 and len(releases) > versions: + url_str = None + elif next_url: + url_str = next_url[0] + else: + url_str = None except: traceback.print_exc() break @@ -261,4 +273,4 @@ def link_latest(name, repo_dir): main() -# vim: ts=4 sw=4 sts=4 expandtab +# vim: ts=4 sw=4 sts=4 expandtab \ No newline at end of file