fix(worker): reorder PlanningAggregator checkout/delete and kill git on cancel

Also stub new IWorkerClient planning members in FakeWorkerClient to restore build.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-04-24 16:24:24 +02:00
parent 4c6fd9f024
commit 9d04d1d9f6
2 changed files with 26 additions and 3 deletions

View File

@@ -78,11 +78,13 @@ public sealed class PlanningAggregator
var integrationBranch = BuildIntegrationBranchName(planning);
// Reset: delete if exists, then recreate off the target branch.
// Reset: checkout target first (so we're never ON the integration branch when deleting it),
// then delete if exists, then recreate off the target branch.
await _git.CheckoutBranchAsync(repoDir, targetBranch, ct);
try { await _git.BranchDeleteAsync(repoDir, integrationBranch, force: true, ct); }
catch { /* didn't exist */ }
await _git.CheckoutBranchAsync(repoDir, targetBranch, ct);
await GitRawAsync(repoDir, ct, "checkout", "-b", integrationBranch);
foreach (var child in childSubtasks)
@@ -150,7 +152,15 @@ public sealed class PlanningAggregator
using var p = System.Diagnostics.Process.Start(psi)!;
var stdoutTask = p.StandardOutput.ReadToEndAsync();
var stderrTask = p.StandardError.ReadToEndAsync();
await p.WaitForExitAsync(ct);
try
{
await p.WaitForExitAsync(ct);
}
catch (OperationCanceledException)
{
try { if (!p.HasExited) p.Kill(entireProcessTree: true); } catch { }
throw;
}
var stdout = await stdoutTask;
var stderr = await stderrTask;
if (p.ExitCode != 0) throw new InvalidOperationException($"git {string.Join(' ', args)} failed: {stderr}");