Skip to content

fix(review): Review a pull request at the merge base of its base branch #5346

Description

@dan-petty

Problem Description

devops review pr reads the files of a pull request from the pulls files endpoint, and it reads their base text at the merge base of the payload's base.sha and the head commit (_pr_base_revision in src/devops_cli/ai/review/runner.py). The command also gives pull.base.sha to the review worktrees as the base revision (src/devops_cli/commands/review.py). GitHub does not move base.sha when a merge commit moves the merge base of a pull request. Thus, after a person merges main into a pull request branch, the review reads a stale file list and a stale base, and it reviews the changes of main as changes of the pull request.

Issue #2530 fixes the same cause in devops pr check-readiness: readiness compares from the tip of the base branch (compare/<base-ref>...<head-sha>). The review runner and devops ai analyze pr still read the pulls files endpoint.

Reproduction Steps

  1. uv run devops gh api repos/dan-petty/devops-cli/pulls/2509 --jq '{base_sha: .base.sha, head: .head.sha, changed_files}' gives base.sha 0137f23, head 344adba and 184 changed files.
  2. uv run devops gh api 'repos/dan-petty/devops-cli/compare/0137f231...344adba9?per_page=1' --jq '{mb: .merge_base_commit.sha, files: (.files|length)}' gives merge base 0137f23 and 184 files. This is the base that the review reads.
  3. uv run devops gh api 'repos/dan-petty/devops-cli/compare/main...344adba9?per_page=1' --jq '{mb: .merge_base_commit.sha, files: (.files|length)}' gives merge base 5c4d24e and 11 files, the files of the squash commit.

Expected vs Actual Behavior

Expected: a review of a pull request reads the files and the base text of the diff that the squash merge applies, which is the compare of the base branch and the head commit.

Actual: the review reads the 184 files of the pulls files endpoint and the base text at 0137f23.

Environment Diagnostics

origin/main on 2026-11-13. Found during the rework of #2530.

Logs, Traces, or Terminal Output

pulls/2509: base.sha 0137f231, head 344adba9, changed_files 184
compare/0137f231...344adba9: merge base 0137f231, 184 files
compare/main...344adba9: merge base 5c4d24ee, 11 files

Activity

  1. added
    source/agent
    type/bug
    scope/review
    status/new
    value/high
    effort/medium
    on Nov 13, 2026
  2. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 13, 2026
  4. removed
    status/in-review
    owner/agent
    on Nov 13, 2026
  5. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor
  6. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-13 12:38 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/reviewsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions