mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 19:55:00 +00:00
style<Repository>: normalize repository's path
This commit is contained in:
parent
1c005983c7
commit
e3a7abe776
7 changed files with 26 additions and 19 deletions
|
@ -209,23 +209,22 @@ namespace SourceGit.ViewModels {
|
|||
}
|
||||
|
||||
public static Repository FindRepository(string path) {
|
||||
var dir = new DirectoryInfo(path);
|
||||
foreach (var repo in _instance.Repositories) {
|
||||
if (repo.FullPath == dir.FullName) return repo;
|
||||
if (repo.FullPath == path) return repo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Repository AddRepository(string rootDir, string gitDir) {
|
||||
var repo = FindRepository(rootDir);
|
||||
var normalized = rootDir.Replace('\\', '/');
|
||||
var repo = FindRepository(normalized);
|
||||
if (repo != null) {
|
||||
repo.GitDir = gitDir;
|
||||
return repo;
|
||||
}
|
||||
|
||||
var dir = new DirectoryInfo(rootDir);
|
||||
repo = new Repository() {
|
||||
FullPath = dir.FullName,
|
||||
FullPath = normalized,
|
||||
GitDir = gitDir
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue