The trailer check reads "Fixes #12" and trusts only a 404

It only recognised trailers written with a colon, so "Fixes #12", which
GitHub closes on just the same, went unchecked, as did fix, fixed, close,
closed, resolve and resolved. The colon is now optional and every closing
keyword counts.

It also treated any failed lookup as a missing issue, so a rate limit or an
outage would have left a public comment on a commit saying a real issue did
not exist. Now only a 404 does that; anything else is a warning in the log.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5 committed 2026-09-21 23:10:27 -04:00
1 parent 2be9fba424
commit 2bb543d29b
1 file changed
+11 -4
+11 -4
View File
@@ -47,16 +47,18 @@ jobs:
# Trailers only: a line that starts with the keyword. A bare "#12"
# in prose is a reference someone wrote on purpose, not a claim
# that this commit closes anything.
# that this commit closes anything. The colon is optional, because
# GitHub closes on "Fixes #12" just as it does on "Fixes: #12", and
# the keywords are every form GitHub accepts, plus refs and see.
refs=$(printf '%s\n' "$msg" \
| grep -oiE '^(fixes|closes|resolves|refs|see):[[:space:]]*([A-Za-z0-9._-]+/[A-Za-z0-9._-]+)?#[0-9]+' \
| grep -oiE '^(fix|fixes|fixed|close|closes|closed|resolve|resolves|resolved|refs|see)(:[[:space:]]*|[[:space:]]+)([A-Za-z0-9._-]+/[A-Za-z0-9._-]+)?#[0-9]+' \
|| true)
[ -z "$refs" ] && continue
while IFS= read -r ref; do
[ -z "$ref" ] && continue
target=$(printf '%s' "$ref" | sed -E 's/^[A-Za-z]+:[[:space:]]*//')
target=$(printf '%s' "$ref" | sed -E 's/^[A-Za-z]+:?[[:space:]]*//')
num="${target##*#}"
if [ "$target" != "#${num}" ]; then
@@ -65,8 +67,13 @@ jobs:
continue
fi
if state=$(gh api "repos/$REPO/issues/$num" --jq .state 2>/dev/null); then
if state=$(gh api "repos/$REPO/issues/$num" --jq .state 2>/tmp/gh.err); then
echo " $short -> #$num ($state)"
elif ! grep -q 'HTTP 404' /tmp/gh.err; then
# Only a 404 means the issue is missing. Anything else (a rate
# limit, an outage) says nothing about the trailer, and a public
# comment calling a real issue missing would be worse than silence.
echo "::warning::could not check #$num for commit $short: $(head -c 200 /tmp/gh.err)"
else
echo "::error::commit $short names #$num, which does not exist in $REPO"
problems=$((problems + 1))