diff --git a/pkg/cmd/pr/create/create.go b/pkg/cmd/pr/create/create.go index a758bf4a4..218be6623 100644 --- a/pkg/cmd/pr/create/create.go +++ b/pkg/cmd/pr/create/create.go @@ -405,8 +405,16 @@ func initDefaultTitleBody(ctx CreateContext, state *shared.IssueMetadataState, o if err != nil { return err } - - if len(commits) == 1 || opts.FillFirst { + if opts.FillFirst { + firstCommitIndex := len(commits) - 1 + state.Title = commits[firstCommitIndex].Title + body, err := gitClient.CommitBody(context.Background(), commits[firstCommitIndex].Sha) + if err != nil { + return err + } + state.Body = body + fmt.Print(state.Title, state.Body) + } else if len(commits) == 1 { state.Title = commits[0].Title body, err := gitClient.CommitBody(context.Background(), commits[0].Sha) if err != nil { diff --git a/pkg/cmd/pr/create/create_test.go b/pkg/cmd/pr/create/create_test.go index 33cb3f19b..9c141ded6 100644 --- a/pkg/cmd/pr/create/create_test.go +++ b/pkg/cmd/pr/create/create_test.go @@ -1008,12 +1008,11 @@ func Test_createRun(t *testing.T) { cs.Register( "git -c log.ShowSignature=false log --pretty=format:%H,%s --cherry origin/master...feature", 0, - `56b6f8bb7c9e3a30093cd17e48934ce354148e80,first commit of pr - 343jdfe47c9e3a30093cd17e48934ce354148e80,second commit of pr - `, + "56b6f8bb7c9e3a30093cd17e48934ce354148e80,second commit of pr\n"+ + "343jdfe47c9e3a30093cd17e48934ce354148e80,first commit of pr", ) cs.Register( - "git -c log.ShowSignature=false show -s --pretty=format:%b 56b6f8bb7c9e3a30093cd17e48934ce354148e80", + "git -c log.ShowSignature=false show -s --pretty=format:%b 343jdfe47c9e3a30093cd17e48934ce354148e80", 0, "first commit description", )