From 4d84e4696a80261c9b27781dbefe3c14bfb1a8af Mon Sep 17 00:00:00 2001 From: Aliabbas Merchant Date: Wed, 10 Jun 2020 16:26:26 +0530 Subject: [PATCH] Reverse the order of commits in `pr create --fill` (#1144) --- command/pr_create.go | 4 ++-- command/pr_create_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/command/pr_create.go b/command/pr_create.go index 07f88c84e..608656f4b 100644 --- a/command/pr_create.go +++ b/command/pr_create.go @@ -40,8 +40,8 @@ func computeDefaults(baseRef, headRef string) (defaults, error) { out.Title = utils.Humanize(headRef) body := "" - for _, c := range commits { - body += fmt.Sprintf("- %s\n", c.Title) + for i := len(commits) - 1; i >= 0; i-- { + body += fmt.Sprintf("- %s\n", commits[i].Title) } out.Body = body } diff --git a/command/pr_create_test.go b/command/pr_create_test.go index e13ecc15f..2eb0872c7 100644 --- a/command/pr_create_test.go +++ b/command/pr_create_test.go @@ -519,7 +519,7 @@ func TestPRCreate_survey_defaults_multicommit(t *testing.T) { }{} _ = json.Unmarshal(bodyBytes, &reqBody) - expectedBody := "- commit 0\n- commit 1\n" + expectedBody := "- commit 1\n- commit 0\n" eq(t, reqBody.Variables.Input.RepositoryID, "REPOID") eq(t, reqBody.Variables.Input.Title, "cool bug fixes")