1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

support bare repositories

This commit is contained in:
Jesse Duffield
2020-09-27 15:36:04 +10:00
parent f9f7f74efb
commit 97af7e677b
4 changed files with 102 additions and 57 deletions

View File

@@ -121,6 +121,7 @@ func NewApp(config config.AppConfigurer, filterPath string) (*App, error) {
if err != nil {
return app, err
}
app.Gui, err = gui.NewGui(app.Log, app.GitCommand, app.OSCommand, app.Tr, config, app.Updater, filterPath, showRecentRepos)
if err != nil {
return app, err
@@ -169,6 +170,11 @@ func (app *App) setupRepo() (bool, error) {
return false, err
}
if os.Getenv("GIT_DIR") != "" {
// we've been given the git dir directly. We'll verify this dir when initializing our GitCommand object
return false, nil
}
// if we are not in a git repo, we ask if we want to `git init`
if err := app.OSCommand.RunCommand("git status"); err != nil {
cwd, err := os.Getwd()
@@ -219,6 +225,14 @@ func (app *App) Run() error {
return err
}
func gitDir() string {
dir := os.Getenv("GIT_DIR")
if dir == "" {
return ".git"
}
return dir
}
// Rebase contains logic for when we've been run in demon mode, meaning we've
// given lazygit as a command for git to call e.g. to edit a file
func (app *App) Rebase() error {
@@ -230,7 +244,7 @@ func (app *App) Rebase() error {
return err
}
} else if strings.HasSuffix(os.Args[1], ".git/COMMIT_EDITMSG") {
} else if strings.HasSuffix(os.Args[1], filepath.Join(gitDir(), "COMMIT_EDITMSG")) { // TODO: test
// if we are rebasing and squashing, we'll see a COMMIT_EDITMSG
// but in this case we don't need to edit it, so we'll just return
} else {