aboutsummaryrefslogtreecommitdiffstats
path: root/repository/gogit.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-09-29 22:00:35 +0200
committerMichael Muré <batolettre@gmail.com>2020-09-29 22:00:35 +0200
commitdb20bc34e5cd696842f459b1d0b8b6aa6457d739 (patch)
tree44f547a041f3fb74f5181681a950c2db7b7b4f33 /repository/gogit.go
parent1204b66e0cc958c2ca3b328d25cbec347356a046 (diff)
downloadgit-bug-db20bc34e5cd696842f459b1d0b8b6aa6457d739.tar.gz
repo: fallback editor list by looking if the binary exist
Diffstat (limited to 'repository/gogit.go')
-rw-r--r--repository/gogit.go18
1 files changed, 17 insertions, 1 deletions
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.