Skip to content

Commit 1df1ba1

Browse files
author
Kit (OpenClaw)
committed
Add script/pr_body_check to validate PR body sections
Adds a shell script that checks whether a PR body contains the required 'Client impact' and 'Verification Plan' sections. Accepts a PR number or URL as an argument, uses the gh CLI to fetch the PR body, and exits non-zero with clear output if either section is missing. Fixes #925
1 parent 4f0cbdf commit 1df1ba1

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

script/pr_body_check

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
# script/pr_body_check
3+
# Validates that a PR body includes required sections.
4+
# Usage: ./script/pr_body_check <PR_NUMBER_OR_URL>
5+
6+
set -euo pipefail
7+
8+
if [[ $# -lt 1 ]]; then
9+
echo "Usage: $0 <PR_NUMBER_OR_URL>" >&2
10+
exit 1
11+
fi
12+
13+
PR_ARG="$1"
14+
15+
# Fetch the PR body via gh CLI
16+
if ! PR_BODY=$(gh pr view "$PR_ARG" --json body --jq '.body' 2>&1); then
17+
echo "Error fetching PR: $PR_BODY" >&2
18+
exit 2
19+
fi
20+
21+
PASS=true
22+
23+
# Case-insensitive check for "Client impact" section
24+
if echo "$PR_BODY" | grep -qi "client impact"; then
25+
echo "\"Client impact\" section found."
26+
else
27+
echo "❌ Missing required section: \"Client impact\"."
28+
PASS=false
29+
fi
30+
31+
# Case-insensitive check for "Verification Plan" section
32+
if echo "$PR_BODY" | grep -qi "verification plan"; then
33+
echo "\"Verification Plan\" section found."
34+
else
35+
echo "❌ Missing required section: \"Verification Plan\"."
36+
PASS=false
37+
fi
38+
39+
if [[ "$PASS" == "false" ]]; then
40+
echo ""
41+
echo "PR body validation FAILED. Please add the missing section(s) above." >&2
42+
exit 1
43+
fi
44+
45+
echo ""
46+
echo "PR body validation PASSED."

0 commit comments

Comments
 (0)