Skip to content

Latest commit

 

History

History
92 lines (67 loc) · 3.46 KB

File metadata and controls

92 lines (67 loc) · 3.46 KB

GitHub: pull-request readiness

The GitHub commands behind the pull-request skill's readiness checklist. The checklist owns every gate, rule and threshold; this file holds the commands it runs.

<owner>/<repo> is the repository bash "<skill-dir>/scripts/target-repo.sh" --dir "<checkout>" prints, <checkout> being the checkout of the PR's repository the session works on, as ready-for-review 2.5.3 defines it. Every command below names it, so none depends on the shell's directory. On a triangular flow (the branch pushed to a fork, the PR opened on its upstream base), the script resolves the checkout to the fork, so the base repository takes its place, named explicitly, as in create's triangular flow: the PR's target, not the push destination.

Discover actors

The checks list shows every check run and commit status. It is a one-off read: poll with the REST read in monitor.md.

gh pr checks <pr_number> -R <owner>/<repo> --json name,state,bucket

The conversation (issue-level) comments, where comment-only actors post:

gh api --paginate "repos/<owner>/<repo>/issues/<pr_number>/comments?per_page=100"

Assert the check-run total

gh api --paginate "repos/<owner>/<repo>/commits/<sha>/check-runs?per_page=100" \
  | jq -s -r '"total_count=\(.[0].total_count) returned=\([.[].check_runs[]] | length)"'

Gate 1: list the checks

gh pr checks <pr_number> -R <owner>/<repo> --json name,state,bucket

gh pr checks aggregates both workflow check-runs and external commit-statuses, which is why one name can show two rows.

Verify a duplicated check name

List every check run on the head (<sha> is the 40-hex head SHA) and find the duplicated name's row in the output:

gh api --paginate "repos/<owner>/<repo>/commits/<sha>/check-runs?per_page=100" \
  --jq '.check_runs[] | [.name, .status, .conclusion] | @tsv'

Gate 2: list failing checks

gh pr checks <pr_number> -R <owner>/<repo> --json name,state,bucket --jq '.[] | select(.bucket == "fail")'

The last-resort log eyeball is gh run view <run-id> -R <owner>/<repo> --log-failed, which truncates at the CLI display layer; see monitor.md.

Gate 4: read the three comment surfaces

# PR reviews (review body — a reviewer that posts no issue comment lands here)
gh api --paginate "repos/<owner>/<repo>/pulls/<pr_number>/reviews?per_page=100" \
  | jq -r '.[] | "\(.user.login): \(.state) — \(.body[:100])"'

# Inline review comments (diff-level)
gh api --paginate "repos/<owner>/<repo>/pulls/<pr_number>/comments?per_page=100" \
  | jq -r '.[] | "\(.user.login): \(.body[:100])"'

# General PR comments (conversation tab)
gh api --paginate "repos/<owner>/<repo>/issues/<pr_number>/comments?per_page=100" \
  | jq -r '.[] | "\(.user.login): \(.body[:100])"'

Gate 5: count inline comments on this head

One reviewer per run, with its discovered login in the --arg login value:

HEAD_SHA=$(git -C "<checkout>" rev-parse HEAD)
gh api --paginate "repos/<owner>/<repo>/pulls/<pr>/comments?per_page=100" \
  | jq -s --arg sha "$HEAD_SHA" --arg login "<discovered reviewer login>" \
    '[.[][] | select(.user.login == $login and .original_commit_id == $sha)] | length'