feat(worker): add PlanningAggregator.CleanupIntegrationBranchAsync

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-04-24 16:34:25 +02:00
parent 1aead9dad0
commit 389d9045d5
3 changed files with 48 additions and 0 deletions

View File

@@ -194,6 +194,26 @@ public class PlanningAggregatorTests : IDisposable
return (parentId, subA, subB);
}
[Fact]
public async Task CleanupIntegrationBranchAsync_RemovesBranchIfPresent()
{
var db = NewDb();
var repo = NewRepo();
GitRepoFixture.RunGit(repo.RepoDir, "branch", "-m", "main");
var (parentId, _, _) = await SeedPlanningWithTwoChildrenAsync(db, repo);
var git = new GitService();
var svc = new PlanningAggregator(db.CreateFactory(), git, NullLogger<PlanningAggregator>.Instance);
var built = await svc.BuildIntegrationBranchAsync(parentId, "main", CancellationToken.None);
var ok = Assert.IsType<CombinedDiffResult.Ok>(built);
await svc.CleanupIntegrationBranchAsync(parentId, CancellationToken.None);
var branches = await git.ListLocalBranchesAsync(repo.RepoDir, CancellationToken.None);
Assert.DoesNotContain(branches, b => b == ok.Value.IntegrationBranch);
}
private void SeedWorktreeWithFile(ClaudeDoDbContext ctx, GitRepoFixture repo, string taskId, string filename, string content)
{
var wtPath = Path.Combine(Path.GetTempPath(), $"wt_{Guid.NewGuid():N}");

View File

@@ -19,6 +19,10 @@ sealed class FakeWorkerClient : IWorkerClient
public int FinalizePlanningCalls { get; private set; }
public int WakeQueueCalls { get; private set; }
public bool IsConnected => false;
public event System.ComponentModel.PropertyChangedEventHandler? PropertyChanged;
public event Action<string, string, DateTime>? TaskStartedEvent;
public event Action<string, string, string, DateTime>? TaskFinishedEvent;
public event Action<string>? TaskUpdatedEvent;
public event Action<string>? WorktreeUpdatedEvent;
public event Action<string, string>? TaskMessageEvent;
@@ -26,6 +30,13 @@ sealed class FakeWorkerClient : IWorkerClient
public void RaiseWorktreeUpdated(string taskId) => WorktreeUpdatedEvent?.Invoke(taskId);
public void RaiseTaskMessage(string taskId, string line) => TaskMessageEvent?.Invoke(taskId, line);
public Task RunNowAsync(string taskId) => Task.CompletedTask;
public Task ContinueTaskAsync(string taskId, string followUpPrompt) => Task.CompletedTask;
public Task ResetTaskAsync(string taskId) => Task.CompletedTask;
public Task CancelTaskAsync(string taskId) => Task.CompletedTask;
public Task<List<AgentInfo>> GetAgentsAsync() => Task.FromResult(new List<AgentInfo>());
public Task<ListConfigDto?> GetListConfigAsync(string listId) => Task.FromResult<ListConfigDto?>(null);
public Task UpdateTaskAgentSettingsAsync(UpdateTaskAgentSettingsDto dto) => Task.CompletedTask;
public Task WakeQueueAsync() { WakeQueueCalls++; return Task.CompletedTask; }
public Task StartPlanningSessionAsync(string taskId, CancellationToken ct = default) { StartPlanningCalls++; return Task.CompletedTask; }
public Task ResumePlanningSessionAsync(string taskId, CancellationToken ct = default) { ResumePlanningCalls++; return Task.CompletedTask; }