Skip to content

Commit 4052b68

Browse files
committed
feature: show Initialize Repository popup when trying to open a folder that is not a git repository from commandline (sourcegit-scm#2354)
Signed-off-by: leo <longshuang@msn.cn>
1 parent 3966807 commit 4052b68

1 file changed

Lines changed: 14 additions & 21 deletions

File tree

src/ViewModels/Launcher.cs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,30 +73,15 @@ public Launcher(string startupRepo)
7373

7474
_ignoreIndexChange = false;
7575

76-
if (TryOpenRepositoryFromPath(startupRepo))
77-
return;
78-
79-
if (!string.IsNullOrEmpty(startupRepo))
80-
{
81-
var test = new Commands.QueryRepositoryRootPath(startupRepo).GetResult();
82-
if (test.IsSuccess && !string.IsNullOrEmpty(test.StdOut))
83-
{
84-
var node = pref.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), null, false);
85-
Welcome.Instance.Refresh();
86-
87-
OpenRepositoryInTab(node, null);
88-
return;
89-
}
90-
}
91-
92-
var activeIdx = ActiveWorkspace.ActiveIdx;
93-
if (activeIdx > 0 && activeIdx < Pages.Count)
76+
if (!TryOpenRepositoryFromPath(startupRepo))
9477
{
95-
ActivePage = Pages[activeIdx];
96-
return;
78+
var activeIdx = ActiveWorkspace.ActiveIdx;
79+
if (activeIdx > 0 && activeIdx < Pages.Count)
80+
ActivePage = Pages[activeIdx];
81+
else
82+
ActivePage = Pages[0];
9783
}
9884

99-
ActivePage = Pages[0];
10085
PostActivePageChanged();
10186
}
10287

@@ -112,6 +97,14 @@ public bool TryOpenRepositoryFromPath(string repo)
11297
OpenRepositoryInTab(node, null);
11398
return true;
11499
}
100+
else
101+
{
102+
if (ActivePage is not { Data: Welcome { }, Popup: null })
103+
AddNewTab();
104+
105+
ActivePage.Popup = new Init(ActivePage.Node.Id, repo, null, 0, test.StdErr ?? "Unknown error occurred while opening the repository.");
106+
return true;
107+
}
115108
}
116109

117110
return false;

0 commit comments

Comments
 (0)