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:
@@ -348,7 +348,8 @@ public sealed class PlanningMergeOrchestratorTests : IDisposable
|
||||
GitRepoFixture.RunGit(repo.RepoDir, "branch", "-m", "main");
|
||||
var (parentId, _, _) = await SeedPlanningWithTwoNonConflictingChildrenAsync(db, repo);
|
||||
|
||||
File.WriteAllText(Path.Combine(repo.RepoDir, "dirty.txt"), "unstaged\n");
|
||||
// Modify a tracked file (real uncommitted change).
|
||||
File.WriteAllText(Path.Combine(repo.RepoDir, "README.md"), "unstaged\n");
|
||||
|
||||
var (orch, _) = BuildOrchestrator(db);
|
||||
|
||||
@@ -357,6 +358,27 @@ public sealed class PlanningMergeOrchestratorTests : IDisposable
|
||||
Assert.Contains("uncommitted", ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task StartAsync_UntrackedFileInRepo_DoesNotThrow()
|
||||
{
|
||||
var db = NewDb();
|
||||
var repo = NewRepo();
|
||||
GitRepoFixture.RunGit(repo.RepoDir, "branch", "-m", "main");
|
||||
var (parentId, subA, subB) = await SeedPlanningWithTwoNonConflictingChildrenAsync(db, repo);
|
||||
|
||||
// An untracked file (e.g. left behind by a concurrent session) must not block the merge.
|
||||
File.WriteAllText(Path.Combine(repo.RepoDir, "untracked.txt"), "stray\n");
|
||||
|
||||
var (orch, _) = BuildOrchestrator(db);
|
||||
|
||||
await orch.StartAsync(parentId, "main", CancellationToken.None);
|
||||
|
||||
using var ctx = db.CreateContext();
|
||||
Assert.Equal(TaskStatus.Done, ctx.Tasks.Single(t => t.Id == parentId).Status);
|
||||
Assert.Equal(WorktreeState.Merged, ctx.Worktrees.Single(w => w.TaskId == subA).State);
|
||||
Assert.Equal(WorktreeState.Merged, ctx.Worktrees.Single(w => w.TaskId == subB).State);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task StartAsync_IdempotentRestart_SkipsAlreadyMergedWorktrees()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user