From c7e702203bef0db6578cd306067e5f829204347b Mon Sep 17 00:00:00 2001 From: Daniel Leong Date: Tue, 8 Sep 2020 20:25:52 -0400 Subject: [PATCH] Update template test to reflect inclusion of "default" text Also, avoid excessive amounts of newlines separating the two --- pkg/cmd/pr/create/create_test.go | 2 +- pkg/cmd/pr/shared/title_body_survey.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/pr/create/create_test.go b/pkg/cmd/pr/create/create_test.go index b947b22a5..f3426702f 100644 --- a/pkg/cmd/pr/create/create_test.go +++ b/pkg/cmd/pr/create/create_test.go @@ -316,7 +316,7 @@ func TestPRCreate_nonLegacyTemplate(t *testing.T) { eq(t, reqBody.Variables.Input.RepositoryID, "REPOID") eq(t, reqBody.Variables.Input.Title, "my title") - eq(t, reqBody.Variables.Input.Body, "Fixes a bug and Closes an issue") + eq(t, reqBody.Variables.Input.Body, "- commit 1\n- commit 0\n\nFixes a bug and Closes an issue") eq(t, reqBody.Variables.Input.BaseRefName, "master") eq(t, reqBody.Variables.Input.HeadRefName, "feature") diff --git a/pkg/cmd/pr/shared/title_body_survey.go b/pkg/cmd/pr/shared/title_body_survey.go index 70308e310..83a50e0ff 100644 --- a/pkg/cmd/pr/shared/title_body_survey.go +++ b/pkg/cmd/pr/shared/title_body_survey.go @@ -2,6 +2,7 @@ package shared import ( "fmt" + "strings" "github.com/AlecAivazis/survey/v2" "github.com/cli/cli/api" @@ -169,6 +170,8 @@ func TitleBodySurvey(io *iostreams.IOStreams, editorCommand string, issueState * if templateContents != "" { if issueState.Body != "" { + // prevent excessive newlines between default body and template + issueState.Body = strings.TrimRight(issueState.Body, "\n") issueState.Body += "\n\n" } issueState.Body += templateContents