feat(git): add GetCurrentBranchAsync

This commit is contained in:
Mika Kuns
2026-04-22 09:22:41 +02:00
parent 32ef1b389a
commit 93ee7b72d5
2 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using ClaudeDo.Data.Git;
using ClaudeDo.Worker.Tests.Infrastructure;
namespace ClaudeDo.Worker.Tests.Runner;
public class GitServiceMergeTests : IDisposable
{
private readonly List<GitRepoFixture> _repos = new();
private GitRepoFixture NewRepo()
{
var r = new GitRepoFixture();
_repos.Add(r);
return r;
}
public void Dispose()
{
foreach (var r in _repos) try { r.Dispose(); } catch { }
}
[Fact]
public async Task GetCurrentBranchAsync_FreshRepo_ReturnsDefaultBranch()
{
if (!GitRepoFixture.IsGitAvailable()) return;
var repo = NewRepo();
var git = new GitService();
var branch = await git.GetCurrentBranchAsync(repo.RepoDir);
Assert.False(string.IsNullOrWhiteSpace(branch));
// Default branch is either "main" or "master" depending on git config.
Assert.True(branch == "main" || branch == "master",
$"Expected main or master, got '{branch}'");
}
}