Skip to content

Commit a22c395

Browse files
committed
code_style: remove unnecessary code
Signed-off-by: leo <[email protected]>
1 parent 84fb39f commit a22c395

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/ViewModels/ScanRepositories.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override Task<bool> Sure()
3131
watch.Start();
3232

3333
var rootDir = new DirectoryInfo(RootDir);
34-
var found = new List<FoundRepository>();
34+
var found = new List<string>();
3535
GetUnmanagedRepositories(rootDir, found, new EnumerationOptions()
3636
{
3737
AttributesToSkip = FileAttributes.Hidden | FileAttributes.System,
@@ -50,20 +50,21 @@ public override Task<bool> Sure()
5050

5151
foreach (var f in found)
5252
{
53-
var parent = new DirectoryInfo(f.Path).Parent!.FullName.Replace('\\', '/').TrimEnd('/');
53+
var parent = new DirectoryInfo(f).Parent!.FullName.Replace('\\', '/').TrimEnd('/');
5454
if (parent.Equals(normalizedRoot, StringComparison.Ordinal))
5555
{
56-
Preferences.Instance.FindOrAddNodeByRepositoryPath(f.Path, null, false, false);
56+
Preferences.Instance.FindOrAddNodeByRepositoryPath(f, null, false, false);
5757
}
5858
else if (parent.StartsWith(normalizedRoot, StringComparison.Ordinal))
5959
{
6060
var relative = parent.Substring(normalizedRoot.Length).TrimStart('/');
6161
var group = FindOrCreateGroupRecursive(Preferences.Instance.RepositoryNodes, relative);
62-
Preferences.Instance.FindOrAddNodeByRepositoryPath(f.Path, group, false, false);
62+
Preferences.Instance.FindOrAddNodeByRepositoryPath(f, group, false, false);
6363
}
6464
}
6565

6666
Preferences.Instance.AutoRemoveInvalidNode();
67+
Preferences.Instance.SortNodes(Preferences.Instance.RepositoryNodes);
6768
Preferences.Instance.Save();
6869

6970
Welcome.Instance.Refresh();
@@ -84,7 +85,7 @@ private void GetManagedRepositories(List<RepositoryNode> group, HashSet<string>
8485
}
8586
}
8687

87-
private void GetUnmanagedRepositories(DirectoryInfo dir, List<FoundRepository> outs, EnumerationOptions opts, int depth = 0)
88+
private void GetUnmanagedRepositories(DirectoryInfo dir, List<string> outs, EnumerationOptions opts, int depth = 0)
8889
{
8990
var subdirs = dir.GetDirectories("*", opts);
9091
foreach (var subdir in subdirs)
@@ -107,7 +108,7 @@ private void GetUnmanagedRepositories(DirectoryInfo dir, List<FoundRepository> o
107108
{
108109
var normalized = test.StdOut.Trim().Replace('\\', '/').TrimEnd('/');
109110
if (!_managed.Contains(normalized))
110-
outs.Add(new FoundRepository(normalized, false));
111+
outs.Add(normalized);
111112
}
112113

113114
continue;
@@ -116,7 +117,7 @@ private void GetUnmanagedRepositories(DirectoryInfo dir, List<FoundRepository> o
116117
var isBare = new Commands.IsBareRepository(subdir.FullName).Result();
117118
if (isBare)
118119
{
119-
outs.Add(new FoundRepository(normalizedSelf, true));
120+
outs.Add(normalizedSelf);
120121
continue;
121122
}
122123

@@ -158,12 +159,6 @@ private RepositoryNode FindOrCreateGroup(List<RepositoryNode> collection, string
158159
return added;
159160
}
160161

161-
private record FoundRepository(string path, bool isBare)
162-
{
163-
public string Path { get; set; } = path;
164-
public bool IsBare { get; set; } = isBare;
165-
}
166-
167-
private HashSet<string> _managed = new HashSet<string>();
162+
private HashSet<string> _managed = new();
168163
}
169164
}

0 commit comments

Comments
 (0)