From afee57181d8eec33c71d5a8bad76784552213f83 Mon Sep 17 00:00:00 2001 From: proactivesprilit Date: Tue, 9 Jan 2024 11:27:09 -0800 Subject: [PATCH] Switch to consuming JSON from GitHub for "latest commit touching file" For some reason, https://github.com/xxx/yyy/commits/HEAD/zzz.atom has recently changed from returning XML by default to returning JSON, which from https://docs.github.com/en/rest/activity/feeds?apiVersion=2022-11-28 seems like it's intentional, so this adds an explicit `Accept:` header (the only explicit JSON one that seems to work) and uses `jq` to determine the latest commit instead of hacking up the XML via `grep`+`awk`. See also https://github.com/docker-library/docker/pull/472 (Additionally, this switches the file to use `wget` consistently instead of a mix of `wget` and `curl`) --- versions.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/versions.sh b/versions.sh index 2677cfbd..8b13d6fc 100755 --- a/versions.sh +++ b/versions.sh @@ -17,10 +17,12 @@ else fi versions=( "${versions[@]%/}" ) -getPipCommit="$(curl -fsSL 'https://github.com/pypa/get-pip/commits/main/public/get-pip.py.atom' | grep -E 'id.*Commit')" -getPipCommit="$(awk <<<"$getPipCommit" -F '[[:space:]]*[<>/]+' '$2 == "id" && $3 ~ /Commit/ { print $4; exit }')" +getPipCommit="$( + wget -qO- --header 'Accept: application/json' 'https://github.com/pypa/get-pip/commits/main/public/get-pip.py.atom' \ + | jq -r '.payload | first(.commitGroups[].commits[].oid)' +)" getPipUrl="https://github.com/pypa/get-pip/raw/$getPipCommit/public/get-pip.py" -getPipSha256="$(curl -fsSL "$getPipUrl" | sha256sum | cut -d' ' -f1)" +getPipSha256="$(wget -qO- "$getPipUrl" | sha256sum | cut -d' ' -f1)" export getPipCommit getPipUrl getPipSha256 has_linux_version() { @@ -64,7 +66,7 @@ for version in "${versions[@]}"; do || : # this page has a very aggressive varnish cache in front of it, which is why we also scrape tags from GitHub - curl -fsSL 'https://www.python.org/ftp/python/' \ + wget -qO- 'https://www.python.org/ftp/python/' \ | grep '