mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature: supports to open a repository directly from commandline (#134)
This commit is contained in:
parent
67e8f35b47
commit
8d6481c694
1 changed files with 21 additions and 1 deletions
|
@ -32,7 +32,27 @@ namespace SourceGit.ViewModels
|
||||||
Pages = new AvaloniaList<LauncherPage>();
|
Pages = new AvaloniaList<LauncherPage>();
|
||||||
AddNewTab();
|
AddNewTab();
|
||||||
|
|
||||||
if (Preference.Instance.RestoreTabs)
|
var commandlines = Environment.GetCommandLineArgs();
|
||||||
|
if (commandlines.Length == 2)
|
||||||
|
{
|
||||||
|
var path = commandlines[1].Replace('\\', '/');
|
||||||
|
var root = new Commands.QueryRepositoryRootPath(path).Result();
|
||||||
|
if (string.IsNullOrEmpty(root))
|
||||||
|
{
|
||||||
|
Pages[0].Notifications.Add(new Models.Notification
|
||||||
|
{
|
||||||
|
IsError = true,
|
||||||
|
Message = $"Given path: '{commandlines[1]}' is NOT a valid repository!"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var gitDir = new Commands.QueryGitDir(root).Result();
|
||||||
|
var repo = Preference.AddRepository(root, gitDir);
|
||||||
|
var node = Preference.FindOrAddNodeByRepositoryPath(repo.FullPath, null);
|
||||||
|
OpenRepositoryInTab(node, null);
|
||||||
|
}
|
||||||
|
else if (Preference.Instance.RestoreTabs)
|
||||||
{
|
{
|
||||||
foreach (var id in Preference.Instance.OpenedTabs)
|
foreach (var id in Preference.Instance.OpenedTabs)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue