Skip to content

Commit c6b46b5

Browse files
rwgkcpcloud
andauthored
Apply reviewer suggestion: Match blocked labels exactly (case-insensitively)
Co-authored-by: Phillip Cloud <417981+cpcloud@users.noreply.github.com>
1 parent 71be2c2 commit c6b46b5

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

.github/workflows/pr-metadata-check.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,18 @@ jobs:
8484
fi
8585
8686
# Block PRs with labels that indicate they are not ready to merge.
87-
# Read labels line-by-line (jq outputs one per line) to handle
88-
# multi-word label names; match with a single regex to avoid
89-
# word-splitting "DO NOT MERGE" into individual grep patterns.
87+
# Match blocked labels exactly (case-insensitively) using the PR
88+
# payload we already have, instead of doing substring matches.
89+
BLOCKED_LABELS=$(jq -r '
90+
[.[].name | ascii_downcase] as $pr_labels
91+
| ["blocked", "do not merge"] as $blocking
92+
| $pr_labels - ($pr_labels - $blocking)
93+
| .[]
94+
' <<<"$LABELS")
9095
while IFS= read -r label; do
91-
if echo "$label" | grep -qiE "blocked|do not merge"; then
92-
ERRORS="${ERRORS}- **Blocked label detected**: label \`$label\` prevents merging. Remove it when the PR is ready.\n"
93-
fi
94-
done < <(echo "$LABELS" | jq -r '.[].name')
96+
[ -n "$label" ] || continue
97+
ERRORS="${ERRORS}- **Blocked label detected**: label \`$label\` prevents merging. Remove it when the PR is ready.\n"
98+
done <<<"$BLOCKED_LABELS"
9599
96100
if [ -n "$ERRORS" ]; then
97101
echo "::error::This PR is missing required metadata. See the job summary for details."

0 commit comments

Comments
 (0)