chore: improve harness feedback workflow (#1561)

This commit is contained in:
Carlos Florêncio
2026-07-01 07:54:19 +01:00
committed by GitHub
parent ec04d3d6e6
commit 818e9c7abc
16 changed files with 324 additions and 101 deletions
+18 -3
View File
@@ -11,6 +11,7 @@
# and URL. Use before deciding how to answer a preview from list.
#
# scripts/pr-resolve reply <PR> <comment_id> <thread_id> <body>
# scripts/pr-resolve reply <PR> <comment_id> <thread_id> --body-file <path>
# Reply to the thread starter, resolve the thread, and add a +1
# reaction in one call. Use this for both "fixed" replies and
# pushback replies — the reply body conveys whether you agreed
@@ -37,7 +38,7 @@ case "$cmd" in
;;
esac
if [[ "$cmd" == "reply" && $# -eq 4 ]]; then
if [[ "$cmd" == "reply" && ( $# -eq 4 || $# -eq 5 ) ]]; then
if [[ "$2" == PRRT_* ]]; then
echo "reply expects comment_id before thread_id; got a review thread ID in the comment_id position" >&2
exit 1
@@ -46,6 +47,15 @@ if [[ "$cmd" == "reply" && $# -eq 4 ]]; then
echo "reply expects thread_id after comment_id; got a non-review-thread ID in the thread_id position" >&2
exit 1
fi
if [[ $# -eq 4 && "$4" == "--body-file" ]]; then
echo "reply --body-file requires a path" >&2
exit 1
fi
if [[ $# -eq 5 ]]; then
[[ "$4" == "--body-file" ]] || usage
[[ -f "$5" ]] || { echo "body file not found: $5" >&2; exit 1; }
[[ -s "$5" ]] || { echo "body file is empty: $5" >&2; exit 1; }
fi
fi
read -r OWNER REPO < <(gh repo view --json owner,name --jq '"\(.owner.login) \(.name)"')
@@ -150,8 +160,13 @@ case "$cmd" in
;;
reply)
[ $# -eq 4 ] || usage
PR=$1; COMMENT_ID=$2; THREAD_ID=$3; BODY=$4
[[ $# -eq 4 || $# -eq 5 ]] || usage
PR=$1; COMMENT_ID=$2; THREAD_ID=$3
if [[ $# -eq 5 ]]; then
BODY=$(<"$5")
else
BODY=$4
fi
gh api -X POST "repos/$OWNER/$REPO/pulls/$PR/comments/$COMMENT_ID/replies" \
-f body="$BODY" --silent
gh api graphql -f query='mutation($t: ID!) { resolveReviewThread(input: {threadId: $t}) { thread { isResolved } } }' \