mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
feature: bare
repository support
This commit is contained in:
parent
cc5f3ebfa5
commit
b9b5220590
6 changed files with 89 additions and 48 deletions
|
@ -34,7 +34,7 @@ namespace SourceGit.ViewModels
|
|||
watch.Start();
|
||||
|
||||
var rootDir = new DirectoryInfo(RootDir);
|
||||
var founded = new List<string>();
|
||||
var founded = new List<FoundRepository>();
|
||||
GetUnmanagedRepositories(rootDir, founded, new EnumerationOptions()
|
||||
{
|
||||
AttributesToSkip = FileAttributes.Hidden | FileAttributes.System,
|
||||
|
@ -47,16 +47,16 @@ namespace SourceGit.ViewModels
|
|||
|
||||
foreach (var f in founded)
|
||||
{
|
||||
var parent = new DirectoryInfo(f).Parent!.FullName.Replace("\\", "/");
|
||||
var parent = new DirectoryInfo(f.Path).Parent!.FullName.Replace("\\", "/");
|
||||
if (parent.Equals(normalizedRoot, StringComparison.Ordinal))
|
||||
{
|
||||
Preferences.Instance.FindOrAddNodeByRepositoryPath(f, null, false);
|
||||
Preferences.Instance.FindOrAddNodeByRepositoryPath(f.Path, null, false);
|
||||
}
|
||||
else if (parent.StartsWith(normalizedRoot, StringComparison.Ordinal))
|
||||
{
|
||||
var relative = parent.Substring(normalizedRoot.Length).TrimStart('/');
|
||||
var group = FindOrCreateGroupRecursive(Preferences.Instance.RepositoryNodes, relative);
|
||||
Preferences.Instance.FindOrAddNodeByRepositoryPath(f, group, false);
|
||||
Preferences.Instance.FindOrAddNodeByRepositoryPath(f.Path, group, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private void GetUnmanagedRepositories(DirectoryInfo dir, List<string> outs, EnumerationOptions opts, int depth = 0)
|
||||
private void GetUnmanagedRepositories(DirectoryInfo dir, List<FoundRepository> outs, EnumerationOptions opts, int depth = 0)
|
||||
{
|
||||
var subdirs = dir.GetDirectories("*", opts);
|
||||
foreach (var subdir in subdirs)
|
||||
|
@ -111,12 +111,19 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
var normalized = test.StdOut.Trim().Replace("\\", "/");
|
||||
if (!_managed.Contains(normalized))
|
||||
outs.Add(normalized);
|
||||
outs.Add(new FoundRepository(normalized, false));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
var isBare = new Commands.IsBareRepository(subdir.FullName).Result();
|
||||
if (isBare)
|
||||
{
|
||||
outs.Add(new FoundRepository(normalizedSelf, true));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (depth < 5)
|
||||
GetUnmanagedRepositories(subdir, outs, opts, depth + 1);
|
||||
}
|
||||
|
@ -161,6 +168,12 @@ namespace SourceGit.ViewModels
|
|||
return added;
|
||||
}
|
||||
|
||||
private record FoundRepository(string path, bool isBare)
|
||||
{
|
||||
public string Path { get; set; } = path;
|
||||
public bool IsBare { get; set; } = isBare;
|
||||
}
|
||||
|
||||
private HashSet<string> _managed = new HashSet<string>();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue