Conversation
📝 WalkthroughWalkthroughThe lint-staged extension was updated to support selecting files by different Git statuses via a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant main.go as main
participant run.go as run
participant git.go as git
participant Task as Task Flow
User->>main: Invoke with --status unstaged
main->>main: Validate --status option<br/>ValidateSelectionMode()
main->>run: runAll(options)
run->>run: Set gitWorkflow.manageIndex<br/>= UsesIndex() [false for unstaged]
run->>Task: Task: Prepare lint-staged
Task->>run: BreakFlow hook (prepareOK)<br/>returns false - continue
run->>git: getSelectedFiles(options)
alt Selection Mode = Unstaged
git->>git: getStatusDiffCommand(diffFilter, false)
git->>git: execGitZ(git diff --name-only -z --diff-filter=... [no --staged])
else Selection Mode = Tracked
git->>git: getTrackedFiles()<br/>= staged + unstaged union
else Selection Mode = All
git->>git: getAllFiles()<br/>= tracked + untracked union
end
git-->>run: Selected files list
run->>run: Backup stash gated on<br/>UsesIndex() [skipped for unstaged]
run->>Task: Task: Running tasks for selected files
Task->>Task: Execute linting on working-tree files
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/lib/tl/list.go`:
- Around line 101-114: The loop in tl.list() discards the BreakFlow reason and
later calls task.skip(p) without a reason, so capture and propagate the
BreakFlow reason: change the BreakFlow handling inside the for loop to extract
both shouldBreak and reason (e.g., shouldBreak, skipReason := task.BreakFlow()),
store skipReason in an outer variable when shouldBreak becomes true, and change
subsequent task.skip calls to pass that reason (e.g., task.skip(p, skipReason));
also update the task.skip signature/implementations (e.g., in
internal/lib/tl/task.go) to accept and record the optional reason so the UI
shows the preserved message like "workspace is clean".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 037bfa9c-650d-4c98-8d3a-1738beeedf8d
📒 Files selected for processing (11)
README.mdinternal/ext/lint-staged/errors.gointernal/ext/lint-staged/git.gointernal/ext/lint-staged/gitWorkflow.gointernal/ext/lint-staged/main.gointernal/ext/lint-staged/messages.gointernal/ext/lint-staged/run.gointernal/ext/lint-staged/selection.gointernal/ext/lint-staged/selection_test.gointernal/lib/tl/list.gointernal/lib/tl/task.go
| shouldBreak := false | ||
|
|
||
| for i, task := range tl.tasks { | ||
| if preventContinue { | ||
| if preventContinue || shouldBreak { | ||
| task.skip(p) | ||
| continue | ||
| } | ||
|
|
||
| taskResult := task.start(p) | ||
| result.SubResults[i] = taskResult | ||
|
|
||
| if task.BreakFlow != nil { | ||
| shouldBreak, _ = task.BreakFlow() | ||
| } |
There was a problem hiding this comment.
Preserve the BreakFlow reason when skipping remaining tasks.
Line 113 discards the reason returned by BreakFlow, and Lines 104-106 skip later tasks without passing one. The lint-staged path returns "workspace is clean", but the UI will show anonymous skips.
🐛 Proposed fix
preventContinue := false
shouldBreak := false
+ breakReason := ""
for i, task := range tl.tasks {
if preventContinue || shouldBreak {
- task.skip(p)
+ task.skip(p, breakReason)
continue
}
taskResult := task.start(p)
result.SubResults[i] = taskResult
if task.BreakFlow != nil {
- shouldBreak, _ = task.BreakFlow()
+ if breakNow, reason := task.BreakFlow(); breakNow {
+ shouldBreak = true
+ breakReason = reason
+ }
}Supporting change in internal/lib/tl/task.go:
-func (t *Task) skip(p *tea.Program) {
+func (t *Task) skip(p *tea.Program, reason string) {
p.Send(&eventTaskSkip{
- Id: t.id,
+ Id: t.id,
+ Reason: reason,
})
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@internal/lib/tl/list.go` around lines 101 - 114, The loop in tl.list()
discards the BreakFlow reason and later calls task.skip(p) without a reason, so
capture and propagate the BreakFlow reason: change the BreakFlow handling inside
the for loop to extract both shouldBreak and reason (e.g., shouldBreak,
skipReason := task.BreakFlow()), store skipReason in an outer variable when
shouldBreak becomes true, and change subsequent task.skip calls to pass that
reason (e.g., task.skip(p, skipReason)); also update the task.skip
signature/implementations (e.g., in internal/lib/tl/task.go) to accept and
record the optional reason so the UI shows the preserved message like "workspace
is clean".
Summary by CodeRabbit
Release Notes
New Features
--statusoption to control which Git-selected files are processed:unstaged,tracked,untracked, orall(default:staged).Documentation