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:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user