Skip to content

fix: allow --range/--pr on clean working tree#472

Merged
tomasz-tomczyk merged 1 commit intomainfrom
fix/471-range-fails-on-clean-tree
May 6, 2026
Merged

fix: allow --range/--pr on clean working tree#472
tomasz-tomczyk merged 1 commit intomainfrom
fix/471-range-fails-on-clean-tree

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

  • crit --range A..B failed with "no changed files detected" when the working tree was clean, even though the requested commit range had changes.
  • Root cause: createSession calls NewSessionFromVCS, which returns ErrNoChangedFiles from working-tree change detection — this fires before SetFocus has a chance to rebuild the file list from the SHA range.
  • Fix: thread a requireChanges flag through a new private newGitSession. When sc.focus != nil, tolerate an empty working-tree diff; applySessionOverridesSetFocus will populate Files from the focus's SHA range.

Review

  • Code review: passed (go-expert + intent validator)
  • Parity audit: N/A (CLI-only Go change)

Test plan

  • New table-driven TestCreateSession_RangeFocus_CleanWorkingTree covers both default-branch and feature-branch shapes (the latter exercises the merge-base recovery branch).
  • New TestCreateSession_NoFocus_CleanWorkingTree pins the default behavior so a future refactor can't silently allow empty sessions.
  • Verified the new tests fail without the fix and pass with it.
  • Full suite green: go test -race ./..., gofmt -l ., golangci-lint run ./....

Closes #471

🤖 Generated with Claude Code

createSession previously called NewSessionFromVCS unconditionally, which
returns ErrNoChangedFiles when the working tree is clean against the base.
With --range or --pr, that check fires before SetFocus has a chance to
rebuild the file list from the requested SHA range, so the daemon spawns,
prints "Started crit daemon at...", then dies with "no changed files
detected" — even though the requested range does have changes.

Skip the empty-changes guard when sc.focus is set; SetFocus will populate
Files from the focus's SHA range during applySessionOverrides.

Closes #471
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.20%. Comparing base (2ad6e2f) to head (5b4bacf).

Files with missing lines Patch % Lines
session.go 75.00% 1 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (77.77%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #472      +/-   ##
==========================================
+ Coverage   69.13%   69.20%   +0.06%     
==========================================
  Files          36       36              
  Lines       10736    10744       +8     
==========================================
+ Hits         7422     7435      +13     
+ Misses       2748     2745       -3     
+ Partials      566      564       -2     
Flag Coverage Δ
e2e 32.39% <22.22%> (-0.15%) ⬇️
unit 66.72% <77.77%> (+0.07%) ⬆️

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 75fa7d5 into main May 6, 2026
7 of 8 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the fix/471-range-fails-on-clean-tree branch May 6, 2026 05:58
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.

crit --range fails on clean working tree before applying range focus

1 participant