fix: --scope changed should detect commits relative to remote base - #1675
Draft
skoshx wants to merge 2 commits into
Draft
fix: --scope changed should detect commits relative to remote base#1675skoshx wants to merge 2 commits into
--scope changed should detect commits relative to remote base#1675skoshx wants to merge 2 commits into
Conversation
…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>
commit: |
Contributor
Interactive terminal E2ETerminal Control verified the built CLI at
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1674 by improving the auto-detection of the base branch for
--scope changedwhen no explicit--baseflag is provided.Root Cause
When running
npx react-doctor --scope changedwithout an explicit--baseflag, thedefaultBranch()function would return the local branch name (e.g.,"main"). When comparingcurrentBranch === baseBranchby name, the code would fall into the "uncommitted changes only" path, missing any committed changes.This affected two scenarios:
mainbranch (onlyorigin/main) would getnullfromdiffSelectionbecausegit merge-base main HEADfailedmainwith committed changes ahead oforigin/mainwould only see uncommitted working-tree changesFix
The
defaultBranch()function now:origin/<branch>) existsorigin/<branch>instead of<branch>when it doesThis ensures:
--scope changedon a feature branch auto-compares againstorigin/main--scope changedon localmainahead oforigin/mainauto-compares against the remotecurrentBranch === baseBranchcorrectly fails, triggering the merge-base pathTesting
Added two regression tests:
main- detects committed changesmainahead oforigin/main- detects committed changesAll core tests pass (2368/2368).
Scope
This change only affects local development when using
--scope changedWITHOUT--base. It does NOT affect:REACT_DOCTOR_BASE_SHAor--changed-files-from)--baseusage (already worked correctly)Closes #1674