From db20bc34e5cd696842f459b1d0b8b6aa6457d739 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 29 Sep 2020 22:00:35 +0200 Subject: repo: fallback editor list by looking if the binary exist --- repository/gogit.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/repository/gogit.go b/repository/gogit.go index 09f714ea..b907c070 100644 --- a/repository/gogit.go +++ b/repository/gogit.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "os" + "os/exec" stdpath "path" "path/filepath" "strings" @@ -231,7 +232,22 @@ func (repo *GoGitRepo) GetCoreEditor() (string, error) { return val, nil } - return "vi", nil + priorities := []string{ + "editor", + "nano", + "vim", + "vi", + "emacs", + } + + for _, cmd := range priorities { + if _, err = exec.LookPath(cmd); err == nil { + return cmd, nil + } + + } + + return "ed", nil } // GetRemotes returns the configured remotes repositories. -- cgit