From 83cbd0138f73e637ad5c31a71a95eaa7651b93a6 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 8 Sep 2026 12:00:37 -0700 Subject: [PATCH] ci: keep the jq expressions parsable on jq 1.6 --- scripts/check-upstream-deps.sh | 4 +++- scripts/unlabel-upstream-deps.sh | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/check-upstream-deps.sh b/scripts/check-upstream-deps.sh index e7627c0c..a308e028 100755 --- a/scripts/check-upstream-deps.sh +++ b/scripts/check-upstream-deps.sh @@ -26,7 +26,9 @@ if [ -z "$PULL_JSON" ] || [ ! -f "$PULL_JSON" ]; then fi body="$(jq -r '.body // ""' "$PULL_JSON")" -labelled="$(jq -r --arg label "$LABEL" '[.labels[]?.name] | index($label) != null' "$PULL_JSON")" +# `label` is a keyword in jq 1.6, which is what the runner image has, so the +# argument cannot be named after it; `(.labels // [])` keeps it parsable there +labelled="$(jq -r --arg want "$LABEL" '[(.labels // [])[].name] | index($want) != null' "$PULL_JSON")" # every gitea# and every pull request url, deduplicated refs="$(printf '%s\n' "$body" \ diff --git a/scripts/unlabel-upstream-deps.sh b/scripts/unlabel-upstream-deps.sh index bc65615f..eeddad64 100755 --- a/scripts/unlabel-upstream-deps.sh +++ b/scripts/unlabel-upstream-deps.sh @@ -27,16 +27,17 @@ gitea_api() { curl "${args[@]}" "$url" } -label_id="$(gitea_api GET "$API/labels?limit=100" | jq -r --arg label "$LABEL" \ - '.[] | select(.name == $label) | .id')" +# see the note in check-upstream-deps.sh about the argument name +label_id="$(gitea_api GET "$API/labels?limit=100" | jq -r --arg want "$LABEL" \ + '.[] | select(.name == $want) | .id')" if [ -z "$label_id" ]; then echo "the repository has no \"$LABEL\" label, nothing to do" exit 0 fi pulls="$(gitea_api GET "$API/pulls?state=open&limit=50")" -indexes="$(printf '%s' "$pulls" | jq -r --arg label "$LABEL" \ - '.[] | select([.labels[]?.name] | index($label) != null) | .number')" +indexes="$(printf '%s' "$pulls" | jq -r --arg want "$LABEL" \ + '.[] | select([(.labels // [])[].name] | index($want) != null) | .number')" if [ -z "$indexes" ]; then echo "no open pull request carries the \"$LABEL\" label"