Skip to content

Commit 5404974

Browse files
committed
fix(ci): fix mirror SHA detection in e2e-label-help workflow
The branches API endpoint cannot handle ref names with slashes (e.g. pull-request/2223). When the API returns a 404, gh api writes the error JSON to stdout before exiting non-zero, so the || fallback never fires. This causes mirror_sha to contain raw JSON like {"message":"Branch not found",...} and the comment displays `{"messa` as the SHA. Switch to the git/ref/heads/ endpoint which handles slashes natively, and add a regex guard to reset mirror_sha to empty when it does not look like a valid 40-char hex SHA. Assisted-By: 🤖 Claude Code Signed-off-by: Roland Huß <roland@ro14nd.de> Signed-off-by: Roland Huß <rhuss@redhat.com>
1 parent 67dc509 commit 5404974

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

.github/workflows/e2e-label-help.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ jobs:
5959
esac
6060
6161
mirror_ref="pull-request/$PR_NUMBER"
62-
mirror_sha=$(gh api "repos/$GH_REPO/branches/$mirror_ref" --jq '.commit.sha' 2>/dev/null || echo "")
62+
mirror_sha=$(gh api "repos/$GH_REPO/git/ref/heads/$mirror_ref" --jq '.object.sha' 2>/dev/null || true)
63+
if [[ ! "$mirror_sha" =~ ^[0-9a-f]{40}$ ]]; then mirror_sha=""; fi
6364
short_pr=${PR_HEAD_SHA:0:7}
6465
6566
if [ -z "$mirror_sha" ]; then

0 commit comments

Comments
 (0)