27 lines
924 B
C#
27 lines
924 B
C#
namespace ClaudeDo.Ui.Services;
|
|
|
|
public sealed record RepoCandidate(string Name, string FullPath);
|
|
|
|
public static class RepoScanner
|
|
{
|
|
public static IReadOnlyList<RepoCandidate> Scan(string parentFolder)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(parentFolder) || !Directory.Exists(parentFolder))
|
|
return Array.Empty<RepoCandidate>();
|
|
|
|
var result = new List<RepoCandidate>();
|
|
IEnumerable<string> subdirs;
|
|
try { subdirs = Directory.EnumerateDirectories(parentFolder); }
|
|
catch (Exception e) when (e is IOException or UnauthorizedAccessException)
|
|
{ return Array.Empty<RepoCandidate>(); }
|
|
|
|
foreach (var dir in subdirs)
|
|
{
|
|
var gitPath = Path.Combine(dir, ".git");
|
|
if (Directory.Exists(gitPath) || File.Exists(gitPath))
|
|
result.Add(new RepoCandidate(Path.GetFileName(dir), dir));
|
|
}
|
|
return result;
|
|
}
|
|
}
|