Skip to content

Commit 6fc428b

Browse files
committed
Normalize .sh line endings; improve label detection
Add .github/scripts/*.sh to .gitattributes to enforce LF normalization for shell scripts. Enhance public_api_label_gate.sh to collect labels from PR_LABELS or, if missing, from the GitHub event payload (using jq), normalize labels to lowercase, and print detected labels before checking for required "breaking" or "feature" labels.
1 parent 7d49023 commit 6fc428b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Auto detect text files and perform LF normalization
22
* text=auto
33
api/public/*.txt text eol=lf
4+
.github/scripts/*.sh text eol=lf

.github/scripts/public_api_label_gate.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ if [[ -z "$changed_snapshots" ]]; then
1515
exit 0
1616
fi
1717

18-
labels=",${PR_LABELS:-},"
19-
if [[ "$labels" == *",breaking,"* || "$labels" == *",feature,"* ]]; then
18+
# Collect labels from env first, then fall back to GitHub event payload.
19+
labels_csv="${PR_LABELS:-}"
20+
if [[ -z "$labels_csv" && -n "${GITHUB_EVENT_PATH:-}" && -f "${GITHUB_EVENT_PATH}" ]]; then
21+
if command -v jq >/dev/null 2>&1; then
22+
labels_csv="$(jq -r '.pull_request.labels[].name' "$GITHUB_EVENT_PATH" 2>/dev/null | paste -sd ',' -)"
23+
fi
24+
fi
25+
26+
labels_normalized=",$(echo "$labels_csv" | tr '[:upper:]' '[:lower:]'),"
27+
echo "Detected PR labels: ${labels_csv:-<none>}"
28+
29+
if [[ "$labels_normalized" == *",breaking,"* || "$labels_normalized" == *",feature,"* ]]; then
2030
echo "Public API snapshots changed and required label is present."
2131
exit 0
2232
fi

0 commit comments

Comments
 (0)