fix(worker): honour targetBranch in MergeAsync by checking out before merge

Add GitService.CheckoutBranchAsync; compare targetBranch to current HEAD
before MergeNoFfAsync and switch when they differ. Returns Blocked if the
branch does not exist. Add three new tests (two service, one GitService).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mika Kuns
2026-04-22 10:25:35 +02:00
parent 1bc7fcc609
commit 953d93179d
4 changed files with 86 additions and 0 deletions

View File

@@ -155,6 +155,20 @@ public class GitServiceMergeTests : IDisposable
Assert.False(await git.IsMidMergeAsync(repo.RepoDir));
}
[Fact]
public async Task CheckoutBranchAsync_ExistingBranch_SwitchesBranch()
{
if (!GitRepoFixture.IsGitAvailable()) return;
var repo = NewRepo();
GitRepoFixture.RunGit(repo.RepoDir, "branch", "feature/checkout-test");
var git = new GitService();
await git.CheckoutBranchAsync(repo.RepoDir, "feature/checkout-test");
var current = await git.GetCurrentBranchAsync(repo.RepoDir);
Assert.Equal("feature/checkout-test", current);
}
[Fact]
public async Task ListConflictedFilesAsync_MidConflict_ReturnsConflictedFile()
{