Authored-By: Codex (GPT-5) <noreply@openai.com>
This commit is contained in:
@@ -32,16 +32,44 @@ if [ -z "${SERVER_URL}" ] || [ -z "${TOKEN}" ]; then
|
||||
elif ! RENDERED_BODY=$(printf '%s' "${BODY}" |
|
||||
jq -Rs '{Text: ., Mode: "gfm"}' |
|
||||
curl --fail --silent --show-error \
|
||||
--connect-timeout 5 \
|
||||
--max-time 15 \
|
||||
--header "Authorization: token ${TOKEN}" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data-binary @- "${SERVER_URL%/}/api/v1/markdown"); then
|
||||
echo "FAIL[check-naming]: Gitea could not render the PR body"
|
||||
FAILED=1
|
||||
fi
|
||||
if printf '%s\n' "${RENDERED_BODY}" | grep -Eiq '<details([[:space:]>])'; then
|
||||
echo "FAIL[check-naming]: rendered PR body must not contain collapsed details"
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
# A collapsed disclosure is valid supporting content, but provenance inside one
|
||||
# is not visible by default. Remove details subtrees before locating sections.
|
||||
VISIBLE_BODY=$(printf '%s\n' "${RENDERED_BODY}" |
|
||||
awk '
|
||||
{
|
||||
line=$0 "\n"
|
||||
for (i=1; i<=length(line); i++) {
|
||||
char=substr(line, i, 1)
|
||||
if (in_tag) {
|
||||
tag=tag char
|
||||
if (char == ">") {
|
||||
lower=tolower(tag)
|
||||
if (lower ~ /^<details([[:space:]>])/) details_depth++
|
||||
else if (lower ~ /^<\/details([[:space:]>])/) {
|
||||
if (details_depth > 0) details_depth--
|
||||
}
|
||||
else if (details_depth == 0) printf "%s", tag
|
||||
in_tag=0
|
||||
tag=""
|
||||
}
|
||||
}
|
||||
else if (char == "<") {
|
||||
in_tag=1
|
||||
tag=char
|
||||
}
|
||||
else if (details_depth == 0) printf "%s", char
|
||||
}
|
||||
}
|
||||
')
|
||||
|
||||
# ---- branch form ----
|
||||
# <role>/bug-<id>/<kebab>
|
||||
@@ -81,7 +109,7 @@ if [ "${BRANCH_KIND}" = "role-bug" ]; then
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
tracking=$(printf '%s\n' "${RENDERED_BODY}" | awk '
|
||||
tracking=$(printf '%s\n' "${VISIBLE_BODY}" | awk '
|
||||
/<h2[^>]*>Tracking<\/h2>/ { in_section=1; next }
|
||||
/<h2[^>]*>/ && in_section { exit }
|
||||
in_section { print }
|
||||
@@ -90,7 +118,7 @@ if [ "${BRANCH_KIND}" = "role-bug" ]; then
|
||||
echo "FAIL[check-naming]: PR body must contain a non-empty ## Tracking section"
|
||||
FAILED=1
|
||||
else
|
||||
if ! printf '%s\n' "${tracking}" | grep -qE "(^|[[:space:]])Fixes[[:space:]]+${BRANCH_BUG}([^a-z0-9]|$)"; then
|
||||
if ! printf '%s\n' "${tracking}" | grep -qE "(^|[[:space:]>])Fixes[[:space:]]+${BRANCH_BUG}([^a-z0-9]|$)"; then
|
||||
echo "FAIL[check-naming]: ## Tracking must contain the literal token 'Fixes ${BRANCH_BUG}'"
|
||||
FAILED=1
|
||||
fi
|
||||
@@ -106,7 +134,7 @@ elif [ "${BRANCH_KIND}" = "chore" ] && [ -n "${TITLE_BUG}" ]; then
|
||||
fi
|
||||
|
||||
if [ "${BRANCH_KIND}" != "invalid" ]; then
|
||||
attribution=$(printf '%s\n' "${RENDERED_BODY}" | awk '
|
||||
attribution=$(printf '%s\n' "${VISIBLE_BODY}" | awk '
|
||||
/<h2[^>]*>Attribution<\/h2>/ { in_section=1; next }
|
||||
/<h2[^>]*>/ && in_section { exit }
|
||||
in_section { print }
|
||||
|
||||
Reference in New Issue
Block a user