Repository navigation
Description
Problem Description
The change of #5346 makes devops review pr and devops ai analyze pr compare <base.ref>...<head>. For a pull request that was merged with a merge commit or a fast-forward, the head is an ancestor of the tip of the base branch. Then the compare lists no files, and the review is empty. This repository squash-merges, so the gap shows only in repositories that allow merge commits.
This is item 2 of #5388. It is split from #5388 because the compare read of the review is only in the open change of #5346. On main, devops review pr reads the pulls diff and the payload base.sha (src/devops_cli/commands/review.py, _run_pr_review_workflow), and that diff holds the files of a merged pull request. So the gap is not on main yet, and a fix on main now stacks on an open pull request.
Reproduction Steps
- Merge the change of fix(review): Review a pull request at the merge base of its base branch #5346.
- Run
devops review pr <number>for a pull request that a merge commit merged, in a repository that allows merge commits.
Live on 2026-11-13: devops gh api 'repos/dan-petty/devops-cli/compare/main...f299667c9?per_page=1' gives status: behind and 0 files, because f299667c9 is a commit of main.
Expected vs Actual Behavior
Expected: for a merged pull request, the review and the analysis read the changes from the merged state: the pulls/{n}/files list or the merge commit. The merged state does not move. For an open pull request, they keep the compare of the base branch and the head commit.
Actual: after the change of #5346, the review and the analysis of a pull request that a merge commit merged read no files.
Acceptance criteria
- A test with a pull request that a merge commit merged shows that
devops review prreads its files. - A test with the same pull request shows that
devops ai analyze prreads its files.
Blocked by
The open change of #5346. Start this item after that change merges.
Existing tool considered
The GitHub pulls and compare APIs, through the GitHub session. No new tool. Cost: about 80,000 tokens, 1 hour elapsed.
Source: #5388
Alternatives check of 2026-11-28: in-use.
The repository already uses this tool.
Tool: gidgethub/gidgethub (https://github.com/gidgethub/gidgethub), Apache-2.0, last activity 2026-11-20, maintained.
Reason: Searches found no external tool that decides between the compare and the merged state; the GitHub client the project already uses covers only the transport, while the branch on pull.merged and the tests stay in the repository.
Covers:
- Paginated read of the pulls files list through the session
- Pulls diff in the diff media type
- One REST transport behind GitHubSession, no new dependency
Lacks:
- No rule to choose compare versus fixed merged state
- No repository tests or GitHub fakes
- No guard against the stale file list of a squash merge
Proposed design
Problem statement
After the change of #5346, devops review pr and devops ai analyze pr read a pull request from the compare of <base.ref>...<head>. When a merge commit or a fast-forward merged the pull request, the head is an ancestor of the base tip, so the compare lists no files and the review is empty. The fix reads such a merged pull request from its fixed merged state, the pulls/{number}/files list and the pulls diff, at the payload's base.sha, and keeps the compare for an open or squash-merged pull request.
Acceptance criteria
Requirement: Merged pull request files list
The pull request content preparation SHALL read the changed files from pulls/{number}/files when the pull request is merged and the compare of its base branch and head lists no files.
Scenario: A merged payload with an empty compare reads the files list
- WHEN A test gives
_prepare_pr_contenta merged pull request payload whose compare lists no files, and a GitHub fake that records each request. - THEN The test asserts a recorded request is
GET /repos/<repo>/pulls/<number>/files?per_page=100and the returned base revision holds each file of the files answer.
Requirement: Merged pull request diff
The pull request content preparation SHALL read the review diff from the pulls endpoint in the diff media type when it reads the files of a merged pull request from pulls/{number}/files.
Scenario: A merged payload reads the pulls diff
- WHEN A test gives
_prepare_pr_contenta merged pull request payload whose compare lists no files and whose pulls endpoint answers a two-file diff. - THEN The test asserts the pages hold the two diff blocks and a recorded request is
GET /repos/<repo>/pulls/<number>with the diff media type.
Requirement: Merged base text
The pull request content preparation SHALL read the base text and the base conventions at the payload's base.sha when it reads the files of a merged pull request from pulls/{number}/files.
Scenario: A merged payload reads the base at base.sha
- WHEN A test gives
_prepare_pr_contenta merged pull request payload whose compare lists no files and abase.shathat differs from the head. - THEN The test asserts the returned base revision names
base.shaand a recorded contents request holdsref=<base.sha>.
Requirement: Squash-merged pull request keeps the compare
The pull request content preparation SHALL read the files and the diff from the compare when the compare of the base branch and the head lists files, also for a merged pull request.
Scenario: A squash-merged payload keeps the compare
- WHEN A test gives a merged pull request payload whose compare lists two files and a GitHub fake that records each request.
- THEN The test asserts no recorded request holds
/pulls/<number>/filesand the pages hold the compare diff.
Requirement: Open pull request keeps the compare
The pull request content preparation SHALL read the changed files from the compare of the base ref and the head SHA when the pull request is not merged.
Scenario: Open payload reads the compare
- WHEN A test gives a pull request payload with
mergedfalse and a GitHub fake that records each request. - THEN The test asserts a recorded request holds
/compare/<base-ref>...<head-sha>?per_page=1and no request holds/pulls/<number>/files.
Requirement: Analyze reads the merged state
devops ai analyze pr SHALL read the changed files from pulls/{number}/files when the pull request is merged and the compare of its base branch and head lists no files.
Scenario: Merged analysis reads the files list
- WHEN A test runs
devops ai analyze prfor a merged pull request whose compare lists no files and a GitHub fake that records each request. - THEN The test asserts a recorded request is
GET /repos/<repo>/pulls/<number>/files?per_page=100and the analysis record holds each file of the files answer.
Requirement: Review of a merged pull request has pages
devops review pr SHALL review the changed files of a merged pull request whose compare lists no files, and never an empty list.
Scenario: Merged review gets its two files
- WHEN A test runs
devops review prfor a merged pull request whose compare lists no files and whose files answer and diff hold two files. - THEN The test asserts the review receives two pages and each page names one of the two files.
Existing Tool Considered
The alternatives check of 2026-11-17 in the issue body found no external tool that covers the choice (Tool: none found), and the issue records No new tool. The open, maintained tool that covers the transport is the one ADR 0006 already chooses: gidgethub 6.0.0 (Apache-2.0), the GitHub REST client behind GitHubSession (docs/adr/0006-github-session-requests-go-through-gidgethub.md:11). It covers the need: GitHubClient.get_pull_files pages GET /repos/{owner}/{repo}/pulls/{number}/files?per_page=100 through GitHubSession.paginate, and GitHubClient.get_pr_diff reads the pulls diff in the diff media type, so the change adds no dependency. What it lacks: it is a transport, not a policy, so it does not decide between the compare of an open or squash-merged pull request and the fixed merged state of a merge-committed or fast-forwarded one, and it supplies no repository tests; _prepare_pr_content and devops ai analyze pr must branch on pull.merged and the empty compare, and the tests must prove both reads. The issue records the cost of the work at about 80,000 tokens and 1 hour elapsed.
Key questions
- Does this item still wait on the change of fix(review): Review a pull request at the merge base of its base branch #5346?: No. The refined
src/devops_cli/ai/review/runner.pycomparespull.base.refandpull.head.shaat line 976, and the fix(review): Review a pull request at the merge base of its base branch #5346 change is archived atopenspec/changes/archive/2026-11-13-5346-review-pr-merge-base/, so the compare read is in the refined commit and the item starts now. [sources: src/devops_cli/ai/review/runner.py:976, openspec/changes/archive/2026-11-13-5346-review-pr-merge-base/tasks.md:18] - Which source gives the changed files and the diff of a merge-committed or fast-forwarded pull request?: Read the files from
GET /repos/{owner}/{repo}/pulls/{number}/filesand the diff from the pulls endpoint in the diff media type, when the pull request is merged and the compare of the base branch and the head lists no files. The pulls files list and the pulls diff are the pull request's own fixed state, andget_pr_diffalready reads that diff. (best practice) [sources: src/devops_cli/github/client.py:648, src/devops_cli/github/client.py:890, tests/support/fakes/github.py:172, openspec/changes/archive/2026-11-13-5346-review-pr-merge-base/proposal.md:37]- Chosen: pulls files list and pulls diff. Both are the pull request's own fixed state, GitHub keeps them after a merge commit or a fast-forward, and the GitHub fake already answers both routes.
- Rejected: diff of the merge commit against its first parent. A fast-forward leaves
merge_commit_shaequal to the head, so the diff holds only the last commit, and a rebase merge leaves it the last rebased commit. - Rejected: compare base...head. The head is an ancestor of the base tip, so the compare gives
status: behindand 0 files, as the live probe of 2026-11-13 in the issue shows.
- Does the fix read the merged state for every merged pull request?: No. It reads the merged state only when the compare of the base branch and the head lists no files, which is the merge-commit and fast-forward case. A squash-merged pull request's head is not an ancestor of the base tip, so its compare still lists the files; the pulls files endpoint and the pulls diff kept 184 files against the 11 of the squash commit for pull request 2509, so routing every merged pull request to them would read the stale list. (best practice) [sources: openspec/changes/archive/2026-11-13-5346-review-pr-merge-base/proposal.md:37, openspec/changes/archive/2026-11-13-5346-review-pr-merge-base/design.md:17, openspec/changes/archive/2026-11-13-2530-readiness-compare-from-base-branch/proposal.md:44, src/devops_cli/ai/review/runner.py:976]
- Chosen: compare first, merged state only when it lists no files. It keeps the correct compare for a squash merge and reaches the fixed merged state only in the merge-commit and fast-forward case the issue names.
- Rejected: every merged pull request reads the pulls files list. Pull request 2509 was squash-merged and the pulls files list held 184 files against 11 in its squash commit, so the review would read the stale list.
- Which base commit does the review of a merged pull request read the base text and the base worktree at?: The payload's
base.sha. The pulls files list and the pulls diff are computed from it: for pull request 2509, the compare frombase.shagave the same 184 files as the pulls files endpoint and the pulls diff, and the review read the conventions there before fix(review): Review a pull request at the merge base of its base branch #5346. It is an ancestor of the head, so the fetch ofrefs/pull/{number}/headbrings it to the local repository. (best practice) [sources: src/devops_cli/github/client.py:74, openspec/changes/archive/2026-11-13-5346-review-pr-merge-base/design.md:17, openspec/changes/archive/2026-11-13-5346-review-pr-merge-base/proposal.md:42, openspec/changes/archive/2026-11-13-2530-readiness-compare-from-base-branch/proposal.md:44]- Chosen: payload base.sha. The pulls files list and the pulls diff are computed from it, and the fetch of the head brings it to the local repository.
- Rejected: merge commit's first parent. It is the base tip at the merge, not the base the pulls endpoints used, so base changes since the merge base would read as removed.
- Rejected: the head SHA. It reads every file as added and gives the base worktree no diff.
- How does the read get each file of a large pull request?: Re-add
GitHubClient.get_pull_files, which readspulls/{number}/files?per_page=100throughGitHubSession.paginate; the session follows each page'sLink: rel="next"until a page has no next link, so a large pull request is read to the end. (best practice) [sources: src/devops_cli/github/session.py:110, src/devops_cli/config/defaults.py:835, CHANGELOG.md:5245]- Chosen: paginate through the session. It follows the next link, the page cap and the error classes that the session already gives, and it is how the pulls files read worked before fix(review): Review a pull request at the merge base of its base branch #5346.
- Rejected: one request with no page parameter. GitHub lists at most 100 files a page, so a larger pull request loses files.
- Rejected: loop over page numbers by hand. It duplicates the
Linkfollowing, page cap and error mapping thatGitHubSession.paginatealready provides.
- Where does
devops ai analyze prprepare the content of a pull request?: Insrc/devops_cli/commands/analyze.py: theprcommand readssession.client.get_pullat line 540, thenget_compare_filesat line 544, and usescompared.filesat line 554. The fix branches there on the merged state, or routes both commands through one shared helper. [sources: src/devops_cli/commands/analyze.py:540, src/devops_cli/commands/analyze.py:544, src/devops_cli/commands/analyze.py:554] - Does the
pr-squash-diffspec change?: Yes. The requirement that the review MUST NOT read the pulls files endpoint or the pulls diff, and the analysis MUST NOT read the pulls files endpoint, now holds for a pull request whose compare lists files; a merged pull request whose compare lists no files reads the pulls files list and the pulls diff at the payload'sbase.sha. The change carries a spec delta forpr-squash-diff. (best practice) [sources: openspec/specs/pr-squash-diff/spec.md:9, openspec/specs/pr-squash-diff/spec.md:31]- Chosen: scope the MUST NOT to the compare read. The spec states the behavior the commands now have, and the merged state gets its own requirement and scenarios.
- Rejected: keep the spec as it is. The commands would read the pulls endpoints while the spec forbids it, so the spec would be wrong.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 13, 2026
Both work on how devops review pr reads PR files in review.py; #5346 changes the read to a compare at merge base, while this candidate fixes the zero-file result that compare gives for a merged PR.fix(github): read the plan diff and the release files from the merge …
devops-cli-service commentedon Nov 17, 2026
Alternatives check: none
Reason: Searches found no tool or library that covers the need: the only candidates are the GitHub REST compare and pulls APIs, which the project already calls through its own GitHub session, and the issue itself records "No new tool". The work is a code change in
devops review pranddevops ai analyze prto read thepulls/{n}/fileslist or the merge commit for a merged pull request, plus tests in this repository, so no external tool covers it.Tool: none found
Lacks:
src/devops_cli/commands/review.py).pulls/{n}/filesor the merge commit itself.devops review pranddevops ai analyze pragainst a pull request merged with a merge commit, which no external tool provides.Searches run:
Sources:
Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 17, 2026
Status set to Ready at 2620fae (see proposed design in issue body).
devops-cli-service commentedon Nov 22, 2026
The result in the alternatives block of the issue body changed. Before this check:
none, no tool. A person decides what the new result means for the item.Searches (7)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 29, 2026
Released in v0.247.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.247.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 16:17 UTC