Skip to content

fix: prefer origin/<default> as diff base over stale local branch#397

Merged
tomasz-tomczyk merged 1 commit intomainfrom
fix-377-origin-default-branch
Apr 30, 2026
Merged

fix: prefer origin/<default> as diff base over stale local branch#397
tomasz-tomczyk merged 1 commit intomainfrom
fix-377-origin-default-branch

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

  • Auto-detected default branch now uses origin/<branch> for merge-base when the remote-tracking ref exists, instead of the bare local name.
  • Local main is often stale relative to origin/main (e.g. when feature branches are based on origin/main after a fetch but before a main fast-forward), producing diffs bloated with already-merged upstream commits.
  • New defaultBaseRef() helper threaded through detectVCSChanges, resolveGitContext, changedFilesOnFeature, and the crit pull codepaths. The base_branch config override is unchanged — already accepts origin/main.
  • VCS interface gains DefaultBaseRef(); Sapling backend returns the bare default (no equivalent remote convention).

Closes #377

Review

  • Code review: passed (no blockers)
  • Parity audit: N/A (Go-only)

Test plan

  • New TestDefaultBaseRef_PrefersOrigin covers no-remote, with-remote, and override paths
  • Existing TestMergeBase_OriginMain (the issue reporter's exact workflow) still passes
  • Full go test -race -count=1 ./... green

🤖 Generated with Claude Code

Auto-detect now diffs against the remote-tracking ref when origin/<defaultBranch>
exists locally, falling back to the bare local name otherwise. The local default
branch is often stale relative to upstream, producing diffs bloated with commits
already merged on the remote.

Closes #377

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.70%. Comparing base (47c7a53) to head (6269891).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
main.go 0.00% 1 Missing ⚠️
sapling.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #397      +/-   ##
==========================================
- Coverage   66.70%   66.70%   -0.01%     
==========================================
  Files          19       19              
  Lines        8211     8220       +9     
==========================================
+ Hits         5477     5483       +6     
- Misses       2310     2312       +2     
- Partials      424      425       +1     
Flag Coverage Δ
e2e 34.06% <46.66%> (+0.03%) ⬆️
unit 62.73% <86.66%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tomasz-tomczyk tomasz-tomczyk merged commit 28c167f into main Apr 30, 2026
8 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the fix-377-origin-default-branch branch April 30, 2026 10:27
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.

Be able to review against remote branches (origin/main vs main)

1 participant