feat(worker): add PlanningAggregator.CleanupIntegrationBranchAsync
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -112,6 +112,23 @@ public sealed class PlanningAggregator
|
||||
return new CombinedDiffResult.Ok(new CombinedDiffSuccess(integrationBranch, unifiedDiff));
|
||||
}
|
||||
|
||||
public async Task CleanupIntegrationBranchAsync(string planningTaskId, CancellationToken ct)
|
||||
{
|
||||
var (planning, repoDir, _) = await LoadPlanningContextAsync(planningTaskId, ct);
|
||||
var branch = BuildIntegrationBranchName(planning);
|
||||
|
||||
var current = await _git.GetCurrentBranchAsync(repoDir, ct);
|
||||
if (string.Equals(current, branch, StringComparison.Ordinal))
|
||||
{
|
||||
var branches = await _git.ListLocalBranchesAsync(repoDir, ct);
|
||||
var target = branches.FirstOrDefault(b => b != branch && !b.StartsWith("claudedo/", StringComparison.Ordinal)) ?? "main";
|
||||
await _git.CheckoutBranchAsync(repoDir, target, ct);
|
||||
}
|
||||
|
||||
try { await _git.BranchDeleteAsync(repoDir, branch, force: true, ct); }
|
||||
catch { /* already gone — idempotent */ }
|
||||
}
|
||||
|
||||
private async Task<(TaskEntity planning, string repoDir, IReadOnlyList<TaskEntity> children)>
|
||||
LoadPlanningContextAsync(string planningTaskId, CancellationToken ct)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user