summaryrefslogtreecommitdiffstats
path: root/pkg/app
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-09-27 15:36:04 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-09-29 17:42:07 +1000
commit97af7e677bfbe18581421b63ceb547b59ee996dd (patch)
tree2a29f67f36249ee541be7bda4dfe4c02270c88bf /pkg/app
parentf9f7f74efb50f601f7b2e8b860faba21154a3b0f (diff)
support bare repositories
Diffstat (limited to 'pkg/app')
-rw-r--r--pkg/app/app.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go
index 31144cc11..6446d8acd 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -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 {