diff --git a/commands/comment_add.go b/commands/comment_add.go index 0a83eb658167af6e01a83f4d08227bff8eaa85ae..8736f9c27fa92ffcb6428691ed23bc00263f69fa 100644 --- a/commands/comment_add.go +++ b/commands/comment_add.go @@ -29,7 +29,7 @@ func runCommentAdd(cmd *cobra.Command, args []string) error { } if commentAddMessage == "" { - commentAddMessage, err = input.BugCommentEditorInput(backend) + commentAddMessage, err = input.BugCommentEditorInput(backend, "") if err == input.ErrEmptyMessage { fmt.Println("Empty message, aborting.") return nil diff --git a/input/input.go b/input/input.go index 6a7c8c7ce285d9baa4ca42d150da80b2ba82a010..07148acc8f1e4e2c3e6369adbfb0e61c12a0ba08 100644 --- a/input/input.go +++ b/input/input.go @@ -78,7 +78,7 @@ func BugCreateEditorInput(repo repository.RepoCommon, preTitle string, preMessag return title, message, nil } -const bugCommentTemplate = ` +const bugCommentTemplate = `%s # Please enter the comment message. Lines starting with '#' will be ignored, # and an empty message aborts the operation. @@ -86,8 +86,9 @@ const bugCommentTemplate = ` // BugCommentEditorInput will open the default editor in the terminal with a // template for the user to fill. The file is then processed to extract a comment. -func BugCommentEditorInput(repo repository.RepoCommon) (string, error) { - raw, err := launchEditorWithTemplate(repo, messageFilename, bugCommentTemplate) +func BugCommentEditorInput(repo repository.RepoCommon, preMessage string) (string, error) { + template := fmt.Sprintf(bugCommentTemplate, preMessage) + raw, err := launchEditorWithTemplate(repo, messageFilename, template) if err != nil { return "", err diff --git a/termui/termui.go b/termui/termui.go index f2163d9626778c524d7f98d27b0c12638d05d696..45952705df6e02570e998b4e5f27edda0b422570 100644 --- a/termui/termui.go +++ b/termui/termui.go @@ -210,7 +210,7 @@ func addCommentWithEditor(bug *cache.BugCache) error { ui.g.Close() ui.g = nil - message, err := input.BugCommentEditorInput(ui.cache) + message, err := input.BugCommentEditorInput(ui.cache, "") if err != nil && err != input.ErrEmptyMessage { return err