From 4eeb62ac7fb7ad98ee0c3d9cf5d888b0990618e3 Mon Sep 17 00:00:00 2001 From: Muddyblack <70057554+Muddyblack@users.noreply.github.com> Date: Mon, 19 Oct 2026 10:19:49 +0200 Subject: [PATCH] fix: explain how to lift GitHub's rate limit when it is hit (#36) Mention the 60 requests per hour anonymous limit and point to a token or the gh CLI login. --- package/contents/tools/sh/nixdatifier | 2 +- package/contents/tools/sh/release-notes | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package/contents/tools/sh/nixdatifier b/package/contents/tools/sh/nixdatifier index 5f77c01..b572e19 100755 --- a/package/contents/tools/sh/nixdatifier +++ b/package/contents/tools/sh/nixdatifier @@ -378,7 +378,7 @@ cmd_notes() { row=$(update_row) || exit $? out=$(NOTE='Fetching release notes…' cached notes 86400 -- timeout --kill-after=5s 60s "$here/release-notes" \ "$(jq -r .url <<<"$row")" "$(jq -r .current <<<"$row")" "$(jq -r .latest <<<"$row")" "$(jq -r .modified <<<"$row")") || - die 'could not fetch release notes (rate limit? set GITHUB_TOKEN or github_token_file)' + die 'could not fetch release notes (rate limit? GitHub allows 60 requests per hour without a login: set GITHUB_TOKEN or github_token_file, or install gh, run gh auth login and set github_use_gh on)' if [[ $fmt == json ]]; then jq . <<<"$out"; return; fi jq -r ' (if .compareUrl != "" then "Compare: \(.compareUrl)\n" else empty end), diff --git a/package/contents/tools/sh/release-notes b/package/contents/tools/sh/release-notes index 098d9f7..af4b107 100755 --- a/package/contents/tools/sh/release-notes +++ b/package/contents/tools/sh/release-notes @@ -83,7 +83,14 @@ fetch() { 200) return 0 ;; 403|429) if grep -qi '^x-ratelimit-remaining: *0' "$tmp/$1.h"; then - echo "GitHub API rate limit reached. Try again later, or set a GitHub token (GITHUB_TOKEN or a token file)." >&2 + local reset + reset=$(sed -n 's/^[Xx]-[Rr]ate[Ll]imit-[Rr]eset: *\([0-9]*\).*/\1/p' "$tmp/$1.h" | head -n1) + reset=$(date -d "@${reset:-0}" +%H:%M 2>/dev/null) || reset="" + if [ -n "$token" ]; then + echo "GitHub API rate limit reached${reset:+ (resets around $reset)}. Try again later." >&2 + else + echo "GitHub API rate limit reached${reset:+ (resets around $reset)}: without a login GitHub allows only 60 requests per hour. Add a GitHub token (GITHUB_TOKEN or a token file in the settings) or install the GitHub CLI (gh), run 'gh auth login' and enable 'Use the GitHub CLI login'." >&2 + fi else echo "GitHub refused the request (HTTP $code)" >&2 fi