mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-11 23:57:21 -08:00
refactor: add repository
This commit is contained in:
parent
52fba29613
commit
275a52eb5c
6 changed files with 12 additions and 13 deletions
|
@ -129,8 +129,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
CallUIThread(() =>
|
CallUIThread(() =>
|
||||||
{
|
{
|
||||||
var normalizedPath = path.Replace("\\", "/");
|
var node = Preference.Instance.FindOrAddNodeByRepositoryPath(path, null, true);
|
||||||
var node = Preference.Instance.FindOrAddNodeByRepositoryPath(normalizedPath, null, true);
|
|
||||||
var launcher = App.GetLauncer();
|
var launcher = App.GetLauncer();
|
||||||
var page = null as LauncherPage;
|
var page = null as LauncherPage;
|
||||||
foreach (var one in launcher.Pages)
|
foreach (var one in launcher.Pages)
|
||||||
|
|
|
@ -38,8 +38,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
CallUIThread(() =>
|
CallUIThread(() =>
|
||||||
{
|
{
|
||||||
var normalizedPath = _targetPath.Replace("\\", "/");
|
Preference.Instance.FindOrAddNodeByRepositoryPath(_targetPath, _parentNode, true);
|
||||||
Preference.Instance.FindOrAddNodeByRepositoryPath(normalizedPath, _parentNode, true);
|
|
||||||
Welcome.Instance.Refresh();
|
Welcome.Instance.Refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -103,8 +103,7 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var normalized = test.StdOut.Trim().Replace("\\", "/");
|
var node = pref.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), null, false);
|
||||||
var node = pref.FindOrAddNodeByRepositoryPath(normalized, null, false);
|
|
||||||
Welcome.Instance.Refresh();
|
Welcome.Instance.Refresh();
|
||||||
OpenRepositoryInTab(node, null);
|
OpenRepositoryInTab(node, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,13 +405,17 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
public RepositoryNode FindOrAddNodeByRepositoryPath(string repo, RepositoryNode parent, bool shouldMoveNode)
|
public RepositoryNode FindOrAddNodeByRepositoryPath(string repo, RepositoryNode parent, bool shouldMoveNode)
|
||||||
{
|
{
|
||||||
var node = FindNodeRecursive(repo, RepositoryNodes);
|
var normalized = repo.Replace('\\', '/');
|
||||||
|
if (normalized.EndsWith("/"))
|
||||||
|
normalized = normalized.TrimEnd('/');
|
||||||
|
|
||||||
|
var node = FindNodeRecursive(normalized, RepositoryNodes);
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
node = new RepositoryNode()
|
node = new RepositoryNode()
|
||||||
{
|
{
|
||||||
Id = repo,
|
Id = normalized,
|
||||||
Name = Path.GetFileName(repo),
|
Name = Path.GetFileName(normalized),
|
||||||
Bookmark = 0,
|
Bookmark = 0,
|
||||||
IsRepository = true,
|
IsRepository = true,
|
||||||
};
|
};
|
||||||
|
|
|
@ -307,8 +307,7 @@ namespace SourceGit.Views
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var normalizedPath = test.StdOut.Trim().Replace("\\", "/");
|
var node = ViewModels.Preference.Instance.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), parent, true);
|
||||||
var node = ViewModels.Preference.Instance.FindOrAddNodeByRepositoryPath(normalizedPath, parent, true);
|
|
||||||
ViewModels.Welcome.Instance.Refresh();
|
ViewModels.Welcome.Instance.Refresh();
|
||||||
|
|
||||||
var launcher = this.FindAncestorOfType<Launcher>()?.DataContext as ViewModels.Launcher;
|
var launcher = this.FindAncestorOfType<Launcher>()?.DataContext as ViewModels.Launcher;
|
||||||
|
|
|
@ -63,8 +63,7 @@ namespace SourceGit.Views
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var normalizedPath = test.StdOut.Trim().Replace("\\", "/");
|
var node = ViewModels.Preference.Instance.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), parent, false);
|
||||||
var node = ViewModels.Preference.Instance.FindOrAddNodeByRepositoryPath(normalizedPath, parent, false);
|
|
||||||
ViewModels.Welcome.Instance.Refresh();
|
ViewModels.Welcome.Instance.Refresh();
|
||||||
|
|
||||||
var launcher = this.FindAncestorOfType<Launcher>()?.DataContext as ViewModels.Launcher;
|
var launcher = this.FindAncestorOfType<Launcher>()?.DataContext as ViewModels.Launcher;
|
||||||
|
|
Loading…
Reference in a new issue