Skip to content

fix: --scope changed should detect commits relative to remote base - #1675

Draft
skoshx wants to merge 2 commits into
mainfrom
cursor/triage-1674-b12b
Draft

fix: --scope changed should detect commits relative to remote base#1675
skoshx wants to merge 2 commits into
mainfrom
cursor/triage-1674-b12b

Conversation

@skoshx

@skoshx skoshx commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1674 by improving the auto-detection of the base branch for --scope changed when no explicit --base flag is provided.

Root Cause

When running npx react-doctor --scope changed without an explicit --base flag, the defaultBranch() function would return the local branch name (e.g., "main"). When comparing currentBranch === baseBranch by name, the code would fall into the "uncommitted changes only" path, missing any committed changes.

This affected two scenarios:

  1. Feature branches without a local main: Users on a feature branch with no local main branch (only origin/main) would get null from diffSelection because git merge-base main HEAD failed
  2. Local main ahead of origin: Users on local main with committed changes ahead of origin/main would only see uncommitted working-tree changes

Fix

The defaultBranch() function now:

  1. Checks if the remote tracking branch (origin/<branch>) exists
  2. Returns origin/<branch> instead of <branch> when it does
  3. Falls back to the old behavior when no remote exists

This ensures:

  • --scope changed on a feature branch auto-compares against origin/main
  • --scope changed on local main ahead of origin/main auto-compares against the remote
  • The name comparison currentBranch === baseBranch correctly fails, triggering the merge-base path

Testing

Added two regression tests:

  1. Feature branch with no local main - detects committed changes
  2. Local main ahead of origin/main - detects committed changes

All core tests pass (2368/2368).

Scope

This change only affects local development when using --scope changed WITHOUT --base. It does NOT affect:

  • CI workflows (GitHub Action provides explicit base via REACT_DOCTOR_BASE_SHA or --changed-files-from)
  • Explicit --base usage (already worked correctly)
  • Parity testing (uses explicit refs)

Closes #1674

Open in Web Open in Cursor 

cursoragent and others added 2 commits August 25, 2026 10:29
…changed

When running --scope changed without an explicit --base, the defaultBranch()
function now returns origin/<branch> instead of just <branch> when the remote
tracking branch exists. This fixes the issue where local commits ahead of the
remote were not detected.

Fixes #1674

Co-authored-by: Skosh <skoshx@users.noreply.github.com>
Co-authored-by: Skosh <skoshx@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Aug 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@1675
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@1675
npm i https://pkg.pr.new/react-doctor@1675

commit: 6e628f6

@github-actions

Copy link
Copy Markdown
Contributor

Interactive terminal E2E

Terminal Control verified the built CLI at 6e628f6 in a real PTY:

  • selected a project interactively and observed Scanning... before the three-second Git delay completed
  • waited for the clean result and exercised the compact report
  • opened copy context and the GitHub Actions confirmation, then cancelled safely

Download the edited MP4 and PNG evidence

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.

Bug: --scope changed does not detect all changed files

2 participants