enhance: when open repository from commandline, create a new workspace Unnamed for it, and never add it to preference (#445)

This commit is contained in:
leo 2024-09-09 19:14:44 +08:00
parent 0190c2111d
commit e63034acd5
No known key found for this signature in database

View file

@ -35,13 +35,15 @@ namespace SourceGit.ViewModels
public Launcher(string startupRepo)
{
var pref = Preference.Instance;
Pages = new AvaloniaList<LauncherPage>();
ActiveWorkspace = pref.GetActiveWorkspace();
AddNewTab();
var repos = _activeWorkspace.Repositories.ToArray();
var pref = Preference.Instance;
if (string.IsNullOrEmpty(startupRepo))
{
ActiveWorkspace = pref.GetActiveWorkspace();
var repos = ActiveWorkspace.Repositories.ToArray();
foreach (var repo in repos)
{
var node = pref.FindNode(repo);
@ -59,12 +61,12 @@ namespace SourceGit.ViewModels
OpenRepositoryInTab(node, null);
}
if (string.IsNullOrEmpty(startupRepo))
{
ActivePage = Pages[0];
}
else
{
ActiveWorkspace = new Workspace() { Name = "Unnamed", Color = 4278221015 };
var test = new Commands.QueryRepositoryRootPath(startupRepo).ReadToEnd();
if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut))
{