Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github-release脚本获取仓库所有release #171

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions github-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,24 @@ 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"
while url_str:
r = github_get(url_str, headers=headers)
r.raise_for_status()
releases.extend(r.json())
next_url = [
s.split(";")[0].strip()[1:-1]
for s in r.headers["link"].split(",")
if s.split(";")[1].strip() == 'rel="next"'
]
if versions > 0 and len(releases) > versions:
jimorsm marked this conversation as resolved.
Show resolved Hide resolved
url_str = None
elif next_url:
url_str = next_url[0]
else:
url_str = None
except:
traceback.print_exc()
break
Expand Down Expand Up @@ -261,4 +276,4 @@ def link_latest(name, repo_dir):
main()


# vim: ts=4 sw=4 sts=4 expandtab
# vim: ts=4 sw=4 sts=4 expandtab