mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-15 15:44:59 +00:00
code_style: remove unnecessary code
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
84fb39f97a
commit
a22c39519f
1 changed files with 9 additions and 14 deletions
|
@ -31,7 +31,7 @@ namespace SourceGit.ViewModels
|
||||||
watch.Start();
|
watch.Start();
|
||||||
|
|
||||||
var rootDir = new DirectoryInfo(RootDir);
|
var rootDir = new DirectoryInfo(RootDir);
|
||||||
var found = new List<FoundRepository>();
|
var found = new List<string>();
|
||||||
GetUnmanagedRepositories(rootDir, found, new EnumerationOptions()
|
GetUnmanagedRepositories(rootDir, found, new EnumerationOptions()
|
||||||
{
|
{
|
||||||
AttributesToSkip = FileAttributes.Hidden | FileAttributes.System,
|
AttributesToSkip = FileAttributes.Hidden | FileAttributes.System,
|
||||||
|
@ -50,20 +50,21 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
foreach (var f in found)
|
foreach (var f in found)
|
||||||
{
|
{
|
||||||
var parent = new DirectoryInfo(f.Path).Parent!.FullName.Replace('\\', '/').TrimEnd('/');
|
var parent = new DirectoryInfo(f).Parent!.FullName.Replace('\\', '/').TrimEnd('/');
|
||||||
if (parent.Equals(normalizedRoot, StringComparison.Ordinal))
|
if (parent.Equals(normalizedRoot, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
Preferences.Instance.FindOrAddNodeByRepositoryPath(f.Path, null, false, false);
|
Preferences.Instance.FindOrAddNodeByRepositoryPath(f, null, false, false);
|
||||||
}
|
}
|
||||||
else if (parent.StartsWith(normalizedRoot, StringComparison.Ordinal))
|
else if (parent.StartsWith(normalizedRoot, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
var relative = parent.Substring(normalizedRoot.Length).TrimStart('/');
|
var relative = parent.Substring(normalizedRoot.Length).TrimStart('/');
|
||||||
var group = FindOrCreateGroupRecursive(Preferences.Instance.RepositoryNodes, relative);
|
var group = FindOrCreateGroupRecursive(Preferences.Instance.RepositoryNodes, relative);
|
||||||
Preferences.Instance.FindOrAddNodeByRepositoryPath(f.Path, group, false, false);
|
Preferences.Instance.FindOrAddNodeByRepositoryPath(f, group, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Preferences.Instance.AutoRemoveInvalidNode();
|
Preferences.Instance.AutoRemoveInvalidNode();
|
||||||
|
Preferences.Instance.SortNodes(Preferences.Instance.RepositoryNodes);
|
||||||
Preferences.Instance.Save();
|
Preferences.Instance.Save();
|
||||||
|
|
||||||
Welcome.Instance.Refresh();
|
Welcome.Instance.Refresh();
|
||||||
|
@ -84,7 +85,7 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetUnmanagedRepositories(DirectoryInfo dir, List<FoundRepository> outs, EnumerationOptions opts, int depth = 0)
|
private void GetUnmanagedRepositories(DirectoryInfo dir, List<string> outs, EnumerationOptions opts, int depth = 0)
|
||||||
{
|
{
|
||||||
var subdirs = dir.GetDirectories("*", opts);
|
var subdirs = dir.GetDirectories("*", opts);
|
||||||
foreach (var subdir in subdirs)
|
foreach (var subdir in subdirs)
|
||||||
|
@ -107,7 +108,7 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
var normalized = test.StdOut.Trim().Replace('\\', '/').TrimEnd('/');
|
var normalized = test.StdOut.Trim().Replace('\\', '/').TrimEnd('/');
|
||||||
if (!_managed.Contains(normalized))
|
if (!_managed.Contains(normalized))
|
||||||
outs.Add(new FoundRepository(normalized, false));
|
outs.Add(normalized);
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -116,7 +117,7 @@ namespace SourceGit.ViewModels
|
||||||
var isBare = new Commands.IsBareRepository(subdir.FullName).Result();
|
var isBare = new Commands.IsBareRepository(subdir.FullName).Result();
|
||||||
if (isBare)
|
if (isBare)
|
||||||
{
|
{
|
||||||
outs.Add(new FoundRepository(normalizedSelf, true));
|
outs.Add(normalizedSelf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,12 +159,6 @@ namespace SourceGit.ViewModels
|
||||||
return added;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
private record FoundRepository(string path, bool isBare)
|
private HashSet<string> _managed = new();
|
||||||
{
|
|
||||||
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