fix(ui): stop treating git worktrees and submodules as repos
.git as a file (worktrees, submodules) isn't a standalone repo — the scanner was flooding the import list with worktree entries alongside their real repo.
This commit is contained in:
@@ -67,9 +67,7 @@ public static class RepoScanner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsRepo(string dir)
|
// A real clone has .git as a directory. Worktrees and submodules have it as a file
|
||||||
{
|
// ("gitdir: ...") — those are not standalone repos and would flood the list.
|
||||||
var gitPath = Path.Combine(dir, ".git");
|
private static bool IsRepo(string dir) => Directory.Exists(Path.Combine(dir, ".git"));
|
||||||
return Directory.Exists(gitPath) || File.Exists(gitPath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,15 +35,17 @@ public sealed class RepoScannerTests : IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Scan_TreatsDotGitFileAsRepo()
|
public void Scan_IgnoresWorktrees()
|
||||||
{
|
{
|
||||||
var repo = MakeDir("worktree-repo");
|
var repo = MakeDir("repo-a");
|
||||||
File.WriteAllText(Path.Combine(repo, ".git"), "gitdir: ../somewhere");
|
Directory.CreateDirectory(Path.Combine(repo, ".git"));
|
||||||
|
var worktree = MakeDir("repo-a-my-task");
|
||||||
|
File.WriteAllText(Path.Combine(worktree, ".git"), "gitdir: ../repo-a/.git/worktrees/my-task");
|
||||||
|
|
||||||
var result = RepoScanner.Scan(_root);
|
var result = RepoScanner.Scan(_root);
|
||||||
|
|
||||||
Assert.Single(result);
|
Assert.Single(result);
|
||||||
Assert.Equal("worktree-repo", result[0].Name);
|
Assert.Equal("repo-a", result[0].Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
Reference in New Issue
Block a user