mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 12:45:00 +00:00
enhance: do not show Initialize Repository
popup for bare repositories (#891)
This commit is contained in:
parent
632222a776
commit
5f4c1bb984
3 changed files with 34 additions and 60 deletions
|
@ -4,7 +4,6 @@ using System.IO;
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
|
@ -36,7 +35,7 @@ namespace SourceGit.Views
|
|||
{
|
||||
var selected = await topLevel.StorageProvider.OpenFolderPickerAsync(options);
|
||||
if (selected.Count == 1)
|
||||
OpenOrInitRepository(selected[0].Path.LocalPath);
|
||||
ViewModels.Welcome.Instance.OpenOrInitRepository(selected[0].Path.LocalPath, null, false);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -45,30 +44,6 @@ namespace SourceGit.Views
|
|||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OpenOrInitRepository(string path, ViewModels.RepositoryNode parent = null)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
if (File.Exists(path))
|
||||
path = Path.GetDirectoryName(path);
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
var test = new Commands.QueryRepositoryRootPath(path).ReadToEnd();
|
||||
if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut))
|
||||
{
|
||||
ViewModels.Welcome.Instance.InitRepository(path, parent, test.StdErr);
|
||||
return;
|
||||
}
|
||||
|
||||
var node = ViewModels.Preferences.Instance.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), parent, false);
|
||||
ViewModels.Welcome.Instance.Refresh();
|
||||
|
||||
var launcher = this.FindAncestorOfType<Launcher>()?.DataContext as ViewModels.Launcher;
|
||||
launcher?.OpenRepositoryInTab(node, launcher.ActivePage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue