R3: --body-file <path>/- across body/comment carriers (#1474)
ci/woodpecker/push/publish Pipeline was canceled

Co-authored-by: marcie <[email protected]>
This commit was merged in pull request #1474.
This commit is contained in:
2026-08-29 22:49:20 +00:00
committed by orch-01
parent ba3b854d50
commit ee6c842918
10 changed files with 199 additions and 0 deletions
@@ -11,6 +11,7 @@ source "$SCRIPT_DIR/detect-platform.sh"
# Parse arguments
PR_NUMBER=""
COMMENT=""
BODY_FILE=""
# Usage-error contract (R4, 2026-08-28): usage errors print to STDERR and exit 2,
# distinct from provider, credential, and verification failures (exit 1), so a
@@ -35,6 +36,12 @@ while [[ $# -gt 0 ]]; do
COMMENT="$2"
shift 2
;;
--body-file)
# R3: body from file (or '-' = stdin); mutually exclusive with --body.
[[ $# -ge 2 && "$2" != --* ]] || usage_error "option $1 requires a path (or - for stdin)"
BODY_FILE="$2"
shift 2
;;
-h|--help)
echo "Usage: pr-close.sh -n <pr_number> [-b <comment>]"
echo ""
@@ -53,6 +60,19 @@ while [[ $# -gt 0 ]]; do
esac
done
# R3 (2026-08-29): resolve --body-file into COMMENT (file or stdin '-');
# exclusive with an explicit --body/--comment value.
if [[ -n "$BODY_FILE" ]]; then
[[ -z "$COMMENT" ]] || usage_error "--body-file and --body are mutually exclusive"
if [[ "$BODY_FILE" == "-" ]]; then
COMMENT=$(cat) || usage_error "could not read body from stdin"
else
[[ -r "$BODY_FILE" ]] || usage_error "body file not readable: $BODY_FILE"
COMMENT=$(cat "$BODY_FILE") || usage_error "could not read body file: $BODY_FILE"
fi
fi
if [[ -z "$PR_NUMBER" ]]; then
usage_error "PR number is required (-n/--number)"
fi