Skip to content

Commit f26690a

Browse files
committed
support GH_EDITOR
1 parent 9641eee commit f26690a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

command/title_body_survey.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package command
22

33
import (
44
"fmt"
5+
"os"
56

67
"github.com/AlecAivazis/survey/v2"
78
"github.com/cli/cli/pkg/githubtemplate"
@@ -82,12 +83,15 @@ func selectTemplate(templatePaths []string) (string, error) {
8283
}
8384

8485
func titleBodySurvey(cmd *cobra.Command, providedTitle, providedBody string, defs defaults, templatePaths []string) (*titleBody, error) {
85-
ctx := contextForCommand(cmd)
86-
cfg, err := ctx.Config()
87-
if err != nil {
88-
return nil, fmt.Errorf("could not read config: %w", err)
86+
editorCommand := os.Getenv("GH_EDITOR")
87+
if editorCommand == "" {
88+
ctx := contextForCommand(cmd)
89+
cfg, err := ctx.Config()
90+
if err != nil {
91+
return nil, fmt.Errorf("could not read config: %w", err)
92+
}
93+
editorCommand, _ = cfg.Get(defaultHostname, "editor")
8994
}
90-
editorCommand, _ := cfg.Get(defaultHostname, "editor")
9195

9296
var inProgress titleBody
9397
inProgress.Title = defs.Title
@@ -135,7 +139,7 @@ func titleBodySurvey(cmd *cobra.Command, providedTitle, providedBody string, def
135139
qs = append(qs, bodyQuestion)
136140
}
137141

138-
err = SurveyAsk(qs, &inProgress)
142+
err := SurveyAsk(qs, &inProgress)
139143
if err != nil {
140144
return nil, fmt.Errorf("could not prompt: %w", err)
141145
}

0 commit comments

Comments
 (0)