Skip to content

Repository scan failed due to case differences in the path on Windows #2230

Description

@gotoh

On Windows.
When I entered "c:\sources" and ran the repository scan, none of the many repositories were added.
Upon investigation with a debugger, it appears that the path returned by DirectoryInfo.GetDirectories() was in uppercase, like "C:\sources", which caused the comparison to fail at the beginning of path.
I think this patch is required.

diff --git a/src/ViewModels/ScanRepositories.cs b/src/ViewModels/ScanRepositories.cs
index e7316dba..5f433d85 100644
--- a/src/ViewModels/ScanRepositories.cs+++ b/src/ViewModels/ScanRepositories.cs@@ -94,14 +94,14 @@ namespace SourceGit.ViewModels
var normalizedRoot = rootDir.FullName.Replace('\\', '/').TrimEnd('/');
foreach (var f in found)
{
var parent = new DirectoryInfo(f).Parent!.FullName.Replace('\\', '/').TrimEnd('/');
- if (parent.Equals(normalizedRoot, StringComparison.Ordinal))+ if (parent.Equals(normalizedRoot, StringComparison.OrdinalIgnoreCase))
{
var node = Preferences.Instance.FindOrAddNodeByRepositoryPath(f, null, false, false);
await node.UpdateStatusAsync(false, null);
}
- else if (parent.StartsWith(normalizedRoot, StringComparison.Ordinal))+ else if (parent.StartsWith(normalizedRoot, StringComparison.OrdinalIgnoreCase))
{
var relative = parent.Substring(normalizedRoot.Length).TrimStart('/');
var group = FindOrCreateGroupRecursive(Preferences.Instance.RepositoryNodes, relative);
var node = Preferences.Instance.FindOrAddNodeByRepositoryPath(f, group, false, false);

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions