Fix pre-commit issues in review-pr skill

Signed-off-by: hsliuustc0106 <liuhongsheng4@huawei.com>
This commit is contained in:
hsliuustc0106 committed 2026-04-13 09:04:40 +08:00
1 parent 901a8db21f
commit 83a153bf70
6 files changed
+18 -19

No files matched your search

+1 -1
View File
@@ -56,7 +56,7 @@ Always run the blocker scan. Under context pressure, do a shallow scan of the mo
## Core Workflow
Check whether this PR is still a draft or WIP in the PR title, if so, end the review process.
Check whether this PR is still a draft or WIP in the PR title, if so, end the review process.
### Step 0: Verify Review Gates First
@@ -115,9 +115,9 @@ curl -s http://localhost:8091/v1/chat/completions \
### Performance Measurements
**Hardware:** 1× NVIDIA A100 80GB
**Resolution:** 1024×1024
**Steps:** 50
**Hardware:** 1× NVIDIA A100 80GB
**Resolution:** 1024×1024
**Steps:** 50
| Metric | Value |
|--------|-------|
@@ -109,4 +109,3 @@ Commands: <exact commands used>
- Changes gated behind a new flag that defaults to disabled (document expected perf when enabled)
**Reviewer-side verification:** For independently verifying contributor perf claims (running benchmarks yourself), see [perf-verification.md](perf-verification.md). This checklist defines what contributors must provide; that reference defines how reviewers can verify it.
@@ -39,11 +39,11 @@ for PR_NUM in $REVIEWED_PRS; do
# Get all review comments on this PR
COMMENTS=$(gh api "repos/${REPO}/pulls/${PR_NUM}/comments" \
--jq '[.[] | {id, user: .user.login, body: .body[:100], in_reply_to_id, created_at, path, url: .html_url}]' 2>/dev/null)
# Find threads: reviewer's comments that got a reply, but reviewer didn't reply back
# 1. Get reviewer's comment IDs
REVIEWER_IDS=$(echo "$COMMENTS" | jq -r --arg r "$REVIEWER" '[.[] | select(.user == $r) | .id]')
# 2. Find replies to reviewer's comments (from others)
REPLIES=$(echo "$COMMENTS" | jq -c --arg r "$REVIEWER" --argjson rids "$REVIEWER_IDS" '
[.[] |
@@ -52,24 +52,24 @@ for PR_NUM in $REVIEWED_PRS; do
select([.in_reply_to_id] | inside($rids))
]
')
REPLY_COUNT=$(echo "$REPLIES" | jq 'length')
if [ "$REPLY_COUNT" -eq 0 ]; then
continue
fi
# 3. For each reply, check if reviewer replied after it
echo "$REPLIES" | jq -c '.[]' | while read -r reply; do
REPLY_ID=$(echo "$reply" | jq -r '.id')
REPLY_DATE=$(echo "$reply" | jq -r '.created_at')
REPLY_USER=$(echo "$reply" | jq -r '.user')
REPLY_URL=$(echo "$reply" | jq -r '.url')
# Check if reviewer replied after this reply
FOLLOWUP=$(echo "$COMMENTS" | jq --arg r "$REVIEWER" --arg date "$REPLY_DATE" --argjson rid "$REPLY_ID" '
[.[] | select(.user == $r) | select(.in_reply_to_id == $rid) | select(.created_at > $date)] | length
')
if [ "$FOLLOWUP" -eq 0 ]; then
REPLY_BODY=$(echo "$reply" | jq -r '.body')
echo "PR #${PR_NUM} | @${REPLY_USER} replied | ${REPLY_URL}"
@@ -54,10 +54,10 @@ echo "Checking review status for $(echo "$FILTERED" | jq length) PRs..." >&2
echo "$FILTERED" | jq -c '.[]' | while read -r pr; do
NUM=$(echo "$pr" | jq -r '.number')
# Get review count
REVIEW_COUNT=$(gh api "repos/${REPO}/pulls/${NUM}/reviews" --jq 'length' 2>/dev/null || echo "0")
# Check if reviewer already reviewed
if [ -n "$REVIEWER" ]; then
ALREADY=$(gh api "repos/${REPO}/pulls/${NUM}/reviews" \
@@ -66,6 +66,6 @@ echo "$FILTERED" | jq -c '.[]' | while read -r pr; do
continue
fi
fi
echo "$pr" | jq --argjson rc "$REVIEW_COUNT" '. + {reviewCount: $rc}'
done | jq -s "sort_by(.reviewCount) | .[:${LIMIT}]"
@@ -23,16 +23,16 @@ echo "$REVIEW_JSON" | jq -c '.comments[]' | while read -r comment; do
FILE=$(echo "$comment" | jq -r '.path')
LINE=$(echo "$comment" | jq -r '.line')
BODY=$(echo "$comment" | jq -r '.body[:60]')
# Extract the file's diff
FILE_DIFF=$(echo "$DIFF" | sed -n "/^diff --git a\/${FILE//\//\/}/,/^diff --git/p" | head -n -1)
if [ -z "$FILE_DIFF" ]; then
echo "ERROR: File not in diff: ${FILE}" >&2
ERRORS=$((ERRORS + 1))
continue
fi
# Check if the line falls within any hunk
IN_HUNK=false
while IFS= read -r hunk_header; do
@@ -40,13 +40,13 @@ echo "$REVIEW_JSON" | jq -c '.comments[]' | while read -r comment; do
NEW_START=$(echo "$hunk_header" | grep -oP '\+\K[0-9]+')
NEW_COUNT=$(echo "$hunk_header" | grep -oP '\+[0-9]+,\K[0-9]+' || echo "1")
NEW_END=$((NEW_START + NEW_COUNT - 1))
if [ "$LINE" -ge "$NEW_START" ] && [ "$LINE" -le "$NEW_END" ]; then
IN_HUNK=true
break
fi
done < <(echo "$FILE_DIFF" | grep '^@@')
if [ "$IN_HUNK" = false ]; then
echo "ERROR: Line ${LINE} in ${FILE} is outside all diff hunks" >&2
echo " Comment: ${BODY}..." >&2