mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-23 01:36:57 -08:00
enhance: do not show Initialize Repository
popup for bare repositories (#891)
This commit is contained in:
parent
a205e17bf2
commit
6e6cd7a7f3
2 changed files with 31 additions and 0 deletions
24
src/Commands/IsBareRepository.cs
Normal file
24
src/Commands/IsBareRepository.cs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace SourceGit.Commands
|
||||||
|
{
|
||||||
|
public class IsBareRepository : Command
|
||||||
|
{
|
||||||
|
public IsBareRepository(string path)
|
||||||
|
{
|
||||||
|
WorkingDirectory = path;
|
||||||
|
Args = "rev-parse --is-bare-repository";
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Result()
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(Path.Combine(WorkingDirectory, "refs")) ||
|
||||||
|
!Directory.Exists(Path.Combine(WorkingDirectory, "objects")) ||
|
||||||
|
!File.Exists(Path.Combine(WorkingDirectory, "HEAD")))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var rs = ReadToEnd();
|
||||||
|
return rs.IsSuccess && rs.StdOut.Trim() == "true";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -300,6 +300,13 @@ namespace SourceGit.Views
|
||||||
return;
|
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();
|
var test = new Commands.QueryRepositoryRootPath(path).ReadToEnd();
|
||||||
if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut))
|
if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue