Merge claudedo/107e62d083e44436b9074c16d14e2edc

This commit is contained in:
mika kuns
2026-08-10 15:02:52 +02:00
9 changed files with 297 additions and 3 deletions
@@ -189,6 +189,26 @@ public class WorktreeManagerTests : IDisposable
Assert.DoesNotContain(task.Id, worktreeList);
}
[Fact]
public async Task CreateAsync_TrailingSeparatorOnWorkingDir_PlacesWorktreeOutsideRepo()
{
if (!GitAvailable) { Assert.True(true, "git not available -- skipping"); return; }
var repo = CreateRepo();
var workingDirWithSeparator = repo.RepoDir + Path.DirectorySeparatorChar;
var (task, list) = MakeEntities(workingDirWithSeparator);
var (mgr, db) = await CreateManagerAsync(task, list);
var ctx = await mgr.CreateAsync(task, list, CancellationToken.None);
_worktreeCleanups.Add((repo.RepoDir, ctx.WorktreePath));
var repoDirFull = Path.GetFullPath(repo.RepoDir);
Assert.False(
ctx.WorktreePath.StartsWith(repoDirFull + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase),
$"worktree path {ctx.WorktreePath} should not be nested inside the repo dir {repoDirFull}");
Assert.True(Directory.Exists(ctx.WorktreePath));
}
private static (TaskEntity task, ListEntity list) MakeEntities(string workingDir)
{
var listId = Guid.NewGuid().ToString();