Fix commit order

This commit is contained in:
Kousik Mitra 2023-05-02 23:42:17 +05:30
parent 1b9906268f
commit 38e6287fe8
2 changed files with 13 additions and 6 deletions

View file

@ -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 {

View file

@ -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",
)