fix(data): merge preflights ignore untracked files in target working tree

HasChangesAsync counted untracked files, so a stray file in the shared
target working dir (e.g. left by a concurrent session) blocked merge
preflights even though nothing tracked changed. Add an includeUntracked
overload defaulting to true, and pass includeUntracked: false only from
the two target-working-tree merge preflights (TaskMergeService.MergeAsync,
PlanningMergeOrchestrator.StartAsync). Auto-commit and the worktree
cleanup data-loss guard keep counting untracked files, since those
callers need to know about them.
This commit is contained in:
mika kuns
2026-07-23 18:14:46 +02:00
parent f18e03354a
commit 14e4c086e2
7 changed files with 102 additions and 8 deletions
@@ -115,7 +115,7 @@ public sealed class TaskMergeService
return Blocked("working directory is not a git repository");
if (await _git.IsMidMergeAsync(list.WorkingDir, ct))
return Blocked("target working directory is mid-merge");
if (await _git.HasChangesAsync(list.WorkingDir, ct))
if (await _git.HasChangesAsync(list.WorkingDir, includeUntracked: false, ct))
return Blocked("target working tree has uncommitted changes");
var currentBranch = await _git.GetCurrentBranchAsync(list.WorkingDir, ct);
@@ -87,7 +87,7 @@ public sealed class PlanningMergeOrchestrator
if (await _git.IsMidMergeAsync(workingDir, ct))
throw new InvalidOperationException(
"repo is mid-merge; use AbortPlanningMerge to reset the repository, then Approve again");
if (await _git.HasChangesAsync(workingDir, ct))
if (await _git.HasChangesAsync(workingDir, includeUntracked: false, ct))
throw new InvalidOperationException("working tree has uncommitted changes");
var idsToMerge = new List<string>();