@@ -9,12 +9,16 @@ Resolve PR review comments, fix CI failures, and address codecov coverage gaps f
99
1010## Step 1: Gather PR State
1111
12+ ** IMPORTANT:** Do NOT use ` gh api --jq ` for extracting data — it uses a built-in jq that
13+ chokes on response bodies containing backslashes (common in Copilot code suggestions).
14+ Always pipe to ` python3 -c ` instead.
15+
1216``` bash
1317# Get PR number
1418PR=$( gh pr view --json number --jq .number)
1519
1620# Get PR head SHA (on remote)
17- HEAD_SHA=$( gh api repos/{owner}/{repo}/pulls/$PR --jq ' .head. sha' )
21+ HEAD_SHA=$( gh api repos/{owner}/{repo}/pulls/$PR | python3 -c " import sys,json; print(json.load(sys.stdin)['head'][' sha']) " )
1822```
1923
2024### 1a. Fetch Review Comments
@@ -23,29 +27,52 @@ Three sources of feedback to check:
2327
2428``` bash
2529# Copilot and user inline review comments (on code lines)
26- gh api repos/{owner}/{repo}/pulls/$PR /comments --jq ' .[] | "[" + .user.login + "] " + .path + ":" + ((.line // .original_line) | tostring) + " — " + .body'
30+ gh api repos/{owner}/{repo}/pulls/$PR /comments | python3 -c "
31+ import sys,json
32+ for c in json.load(sys.stdin):
33+ line = c.get('line') or c.get('original_line') or '?'
34+ print(f'[{c[\" user\" ][\" login\" ]}] {c[\" path\" ]}:{line} — {c[\" body\" ]}')
35+ "
2736
2837# Review-level comments (top-level review body)
29- gh api repos/{owner}/{repo}/pulls/$PR /reviews --jq ' .[] | select(.body != "") | "[" + .user.login + "] " + .state + ": " + .body'
38+ gh api repos/{owner}/{repo}/pulls/$PR /reviews | python3 -c "
39+ import sys,json
40+ for r in json.load(sys.stdin):
41+ if r.get('body'):
42+ print(f'[{r[\" user\" ][\" login\" ]}] {r[\" state\" ]}: {r[\" body\" ]}')
43+ "
3044
31- # Issue-level comments (general discussion)
32- gh api repos/{owner}/{repo}/issues/$PR /comments --jq ' .[] | select(.user.login | test("codecov|copilot") | not) | "[" + .user.login + "] " + .body'
45+ # Issue-level comments (general discussion, excluding bots)
46+ gh api repos/{owner}/{repo}/issues/$PR /comments | python3 -c "
47+ import sys,json
48+ for c in json.load(sys.stdin):
49+ login = c['user']['login']
50+ if 'codecov' not in login and 'copilot' not in login:
51+ print(f'[{login}] {c[\" body\" ]}')
52+ "
3353```
3454
3555### 1b. Check CI Status
3656
3757``` bash
3858# All check runs on the PR head
39- gh api repos/{owner}/{repo}/commits/$HEAD_SHA /check-runs \
40- --jq ' .check_runs[] | .name + ": " + (.conclusion // .status)'
59+ gh api repos/{owner}/{repo}/commits/$HEAD_SHA /check-runs | python3 -c "
60+ import sys,json
61+ for cr in json.load(sys.stdin)['check_runs']:
62+ print(f'{cr[\" name\" ]}: {cr.get(\" conclusion\" ) or cr[\" status\" ]}')
63+ "
4164```
4265
4366### 1c. Check Codecov Report
4467
4568``` bash
4669# Codecov bot comment with coverage diff
47- gh api repos/{owner}/{repo}/issues/$PR /comments \
48- --jq ' .[] | select(.user.login == "codecov[bot]") | .body'
70+ gh api repos/{owner}/{repo}/issues/$PR /comments | python3 -c "
71+ import sys,json
72+ for c in json.load(sys.stdin):
73+ if c['user']['login'] == 'codecov[bot]':
74+ print(c['body'])
75+ "
4976```
5077
5178## Step 2: Triage and Prioritize
@@ -102,9 +129,13 @@ For detailed line-by-line coverage, use the Codecov API:
102129
103130``` bash
104131# Get file-level coverage for the PR
105- gh api repos/{owner}/{repo}/pulls/$PR /comments \
106- --jq ' .[] | select(.user.login == "codecov[bot]") | .body' \
107- | sed -n ' s/.*filepath=\([^&]*\).*/\1/p'
132+ gh api repos/{owner}/{repo}/issues/$PR /comments | python3 -c "
133+ import sys,json,re
134+ for c in json.load(sys.stdin):
135+ if c['user']['login'] == 'codecov[bot]':
136+ for m in re.findall(r'filepath=([^&\" ]+)', c['body']):
137+ print(m)
138+ "
108139```
109140
110141Then read the source files and identify which new/changed lines lack test coverage.
0 commit comments