mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-12 11:15:00 +02:00
Check for bare repositories
This commit is contained in:
parent
367b0d3318
commit
41b54d742f
@ -151,6 +151,17 @@ func isDirectoryAGitRepository(dir string) (bool, error) {
|
|||||||
return info != nil && info.IsDir(), err
|
return info != nil && info.IsDir(), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isBareRepo(osCommand *oscommands.OSCommand) (bool, error) {
|
||||||
|
res, err := osCommand.Cmd.New("git rev-parse --is-bare-repository").DontLog().RunWithOutput()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// The command returns output with a newline, so we need to strip
|
||||||
|
return strconv.ParseBool(strings.TrimSpace(res))
|
||||||
|
}
|
||||||
|
|
||||||
func (app *App) setupRepo() (bool, error) {
|
func (app *App) setupRepo() (bool, error) {
|
||||||
if err := app.validateGitVersion(); err != nil {
|
if err := app.validateGitVersion(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -167,6 +178,7 @@ func (app *App) setupRepo() (bool, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if isRepo, err := isDirectoryAGitRepository(cwd); isRepo {
|
if isRepo, err := isDirectoryAGitRepository(cwd); isRepo {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@ -210,6 +222,17 @@ func (app *App) setupRepo() (bool, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run this afterward so that the previous repo creation steps can run without this interfering
|
||||||
|
if isBare, err := isBareRepo(app.OSCommand); isBare {
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if isBare {
|
||||||
|
log.Fatalln("bare repositories are not supported by lazygit, please make this a working repository.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user