Skip to content

Show whether a PR is approved in git pr - #235

Merged
haacked merged 1 commit into
mainfrom
haacked/git-pr-review-status
Oct 7, 2026
Merged

haacked merged 1 commit into
mainfrom
haacked/git-pr-review-status

Conversation

@haacked

@haacked haacked commented Oct 7, 2026

Copy link
Copy Markdown
Owner

git pr printed Ready for every open PR that wasn't approved, so its output couldn't tell you whether a PR was approved. In a repo that requires no reviews, a PR whose reviewer approved and then left a comment also read as not approved, because the fallback read latestReviews, which keeps each reviewer's newest review of any kind.

An open, non-draft PR now shows Approved, Changes requested, Review required (the base branch requires an approval the PR lacks), or Not approved (the base branch requires none and no approval counts). Stack lines use the same labels.

https://github.com/PostHog/posthog/pull/112066 (Review required)
https://github.com/haacked/haacked.com/pull/4093 (Not approved)

When GitHub gives no review decision, the status comes from reviews: each reviewer's last approval, change request, or dismissal. GraphQL's latestOpinionatedReviews answers this directly, but gh --json doesn't expose it, and switching the lookups to gh api graphql would rewrite most of the script.

reviews returns every review, so a lookup on a branch name that many forks share got slower: 1.5s to 2.05s for one that matched 13 fork PRs. gh pr list also returns only a PR's oldest 100 reviews, so in a repo that requires no reviews, an approval after the first 100 doesn't count. gh pr view pages through all of them.

Test plan

  • bin/lib/test-git-pr.sh passes 113 cases, including an approval followed by a comment, a change request followed by an approval, and pending and dismissed reviews after an approval
  • The portable-skill tests and ai/bin/sync-portable-skills.sh --check pass
  • Live runs print Review required for posthog PRs awaiting review, Not approved for an unreviewed haacked.com PR, and Approved for two PRs whose reviewer approved and then commented

https://claude.ai/code/session_01FLq8eNPjDPRau2RPMnVDTj

An open PR that was not approved printed "Ready". It now prints "Review
required" when the base branch requires an approval, and "Not approved"
when it requires none. Without a review decision, the status comes from
each reviewer's last approval, change request, or dismissal, so a comment
after an approval no longer hides it.

Claude-Session: https://claude.ai/code/session_01FLq8eNPjDPRau2RPMnVDTj

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The status logic is consistent across bundled copies and covers the relevant review-state transitions with focused tests.

0 open findings

What changed in this PR

Updates git pr to report accurate review states for open pull requests and stacked PRs.

Changes:

  • Adds Review required and Not approved statuses.
  • Derives fallback status from each reviewer’s latest meaningful review.
  • Expands coverage for review transitions and stack output.
File Description
bin/​git-pr Implements improved review-status calculation.
bin/​lib/​test-git-pr.sh Tests status mapping and review transitions.
ai/​skills/​wait-for-pr-reviews/​scripts/​git-pr Synchronizes the portable helper.
ai/​skills/​address-pr-reviews/​scripts/​git-pr Synchronizes the portable helper.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@haacked
haacked marked this pull request as ready for review October 7, 2026 17:26
@haacked
haacked merged commit 4bf90ba into main Oct 7, 2026
2 checks passed
@haacked
haacked deleted the haacked/git-pr-review-status branch October 7, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants