Skip to content

Commit

Permalink
Switch to consuming JSON from GitHub for "latest commit touching file"
Browse files Browse the repository at this point in the history
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 docker-library/docker#472

(Additionally, this switches the file to use `wget` consistently instead of a mix of `wget` and `curl`)
  • Loading branch information
proactivesprilit committed Jan 9, 2024
1 parent c15be71 commit afee571
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 '<a href="'"$rcVersion." \
| sed -r 's!.*<a href="([^"/]+)/?".*!\1!' \
| grep $rcGrepV -E -- '[a-zA-Z]+' \
Expand Down

0 comments on commit afee571

Please sign in to comment.