Skip to content

Commit a462ab4

Browse files
committed
Use requests link parsing
1 parent f6d5c35 commit a462ab4

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

ci/github_releases.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,13 @@ def github_paginated(session, url):
5555
Get all the results from a paginated GitHub url.
5656
"""
5757
while True:
58-
print(f"GETTING: {url}")
5958
resp = session.get(url)
6059
check_ok(resp)
6160
yield from resp.json()
62-
if 'Link' not in resp.headers:
63-
break
64-
links = resp.headers['link'].split(",")
65-
next_link = next((link for link in links if 'rel="next"' in link), None)
61+
next_link = resp.links.get("next", None)
6662
if not next_link:
6763
break
68-
url = next_link.split(";")[0].strip(" <>")
64+
url = next_link["url"]
6965

7066
def get_releases(session, repo):
7167
"""
@@ -74,7 +70,7 @@ def get_releases(session, repo):
7470
Returns:
7571
A dict mapping tag names to release dictionaries.
7672
"""
77-
url = RELEASES_URL.format(repo=repo) + "?per_page=100"
73+
url = RELEASES_URL.format(repo=repo)
7874
releases = { r['tag_name']: r for r in github_paginated(session, url) }
7975
return releases
8076

0 commit comments

Comments
 (0)