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 `hack/dind` commit instead of hacking up the XML via `grep`+`awk`.

See also docker-library/docker#472
  • Loading branch information
tianon authored and SammyEnigma committed Jun 2, 2024
1 parent 482e90c commit eafc27e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .libs/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ github-file-commit() {
[ -n "$file" ]

local atom
atom="$(wget -qO- "https://github.com/$repo/commits/$branch/$file.atom")"
atom="$(wget -qO- --header 'Accept: application/json' "https://github.com/$repo/commits/$branch/$file.atom")"
local commit
commit="$(awk <<<"$atom" -F ' *[<>/]+' '$2 == "id" && $3 ~ /Commit/ { print $4; exit }')"
commit="$(jq <<<"$atom" -r '.payload | first(.commitGroups[].commits[].oid)')"

echo >&2 "github $repo - $file: $commit"

Expand Down

0 comments on commit eafc27e

Please sign in to comment.