Skip to content

Choose the base ref used to compare the current branch - #14

Draft
felipeorlando wants to merge 1 commit into
mainfrom
issue-6-compare-base
Draft

felipeorlando wants to merge 1 commit into
mainfrom
issue-6-compare-base

Conversation

@felipeorlando

Copy link
Copy Markdown
Owner

Closes #6

The compare base is now selectable instead of hardcoded to the repository default. For stacked branches, release branches and worktrees started from another feature branch, the previous diff was simply wrong.

Rust (src-tauri/src/fs.rs) — new CompareBase { name, spec }, git_resolve_base (accepts main, feature/x or origin/main, preferring the remote copy like the old default-branch logic) and git_compare_base, which returns Err("Compare base \"x\" no longer exists") rather than falling through to another branch. git_range_context_for takes base: Option<&str> and builds three-dot <resolved base>...HEAD. git_diff_index gains base, base_ref, base_error, ahead_of_base (renamed from ahead_of_default), branch_files, branch_additions, branch_deletions.

Status views fall back to the repo default and report base_error; PR generation does not fall back — a PR must never be retargeted silently.

TypeScriptcompareBase.ts persists per folder keyed by projectKey(cwd), so a worktree and its parent checkout keep separate bases; the repo default is stored as absence, so a repo that renames its default follows along. CompareBasePicker.tsx is modelled on BranchPicker but only changes the compare ref — it never calls checkout. GitChangesPanel gains a CompareBar rendering branch → base ▾ plus branch-level counts, with an amber fallback line when baseError is set. PR generation uses the resolved base the UI is displaying, not the raw preference.

The working-tree/index view, staging flags and ahead/behind are untouched.

Verification

npm run check (web and rust) — exit 0:

  • 129 files / 1336 tests, tsc --noEmit clean
  • cargo fmt --check clean, clippy -D warnings no warnings, cargo test 214 passed

9 new Rust #[test]s on real temp repos, including stacked main → feature-a → feature-b, deleted-base error, deleted-base fallback with base_error, per-base counts asserting the checkout is unchanged, and a three-dot test proving commits added to the base after the fork are excluded.

Not done / not verified

  • No runtime UI verification — the Tauri app was never launched, so CompareBar layout and popover placement are unverified beyond types and unit tests.
  • Worktree "start-from ref" default not implemented. The issue makes it conditional on that metadata being available, and it isn't: Session.worktreeCwd is marked unused and nothing records a start-from ref. (Start a new session in the main checkout or a selected/new worktree #2 would change this.)
  • The commit graph still pins its tips to the repo default (git_history_tips). The acceptance criteria cover changed files/counts, PR context and PR target only.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

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.

Choose the base ref used to compare the current branch

1 participant