Skip to content

Commit c7e7022

Browse files
committed
Update template test to reflect inclusion of "default" text
Also, avoid excessive amounts of newlines separating the two
1 parent 41543b5 commit c7e7022

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

pkg/cmd/pr/create/create_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func TestPRCreate_nonLegacyTemplate(t *testing.T) {
316316

317317
eq(t, reqBody.Variables.Input.RepositoryID, "REPOID")
318318
eq(t, reqBody.Variables.Input.Title, "my title")
319-
eq(t, reqBody.Variables.Input.Body, "Fixes a bug and Closes an issue")
319+
eq(t, reqBody.Variables.Input.Body, "- commit 1\n- commit 0\n\nFixes a bug and Closes an issue")
320320
eq(t, reqBody.Variables.Input.BaseRefName, "master")
321321
eq(t, reqBody.Variables.Input.HeadRefName, "feature")
322322

pkg/cmd/pr/shared/title_body_survey.go

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

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

67
"github.com/AlecAivazis/survey/v2"
78
"github.com/cli/cli/api"
@@ -169,6 +170,8 @@ func TitleBodySurvey(io *iostreams.IOStreams, editorCommand string, issueState *
169170

170171
if templateContents != "" {
171172
if issueState.Body != "" {
173+
// prevent excessive newlines between default body and template
174+
issueState.Body = strings.TrimRight(issueState.Body, "\n")
172175
issueState.Body += "\n\n"
173176
}
174177
issueState.Body += templateContents

0 commit comments

Comments
 (0)