mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 13:14:59 +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
|
@ -83,6 +83,37 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void OpenOrInitRepository(string path, RepositoryNode parent, bool bMoveExistedNode)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
if (File.Exists(path))
|
||||
path = Path.GetDirectoryName(path);
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
var isBare = new Commands.IsBareRepository(path).Result();
|
||||
if (isBare)
|
||||
{
|
||||
App.RaiseException(string.Empty, $"'{path}' is a bare repository, which is not supported by SourceGit!");
|
||||
return;
|
||||
}
|
||||
|
||||
var test = new Commands.QueryRepositoryRootPath(path).ReadToEnd();
|
||||
if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut))
|
||||
{
|
||||
InitRepository(path, parent, test.StdErr);
|
||||
return;
|
||||
}
|
||||
|
||||
var node = Preferences.Instance.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), parent, bMoveExistedNode);
|
||||
Refresh();
|
||||
|
||||
var launcher = App.GetLauncer();
|
||||
launcher?.OpenRepositoryInTab(node, launcher.ActivePage);
|
||||
}
|
||||
|
||||
public void InitRepository(string path, RepositoryNode parent, string reason)
|
||||
{
|
||||
if (!Preferences.Instance.IsGitConfigured())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue