(ctx CreateContext, state *shared.IssueMetadataState, useFirstCommit bool, addBody bool)
| 643 | var regexPattern = regexp.MustCompile(`(?m)^`) |
| 644 | |
| 645 | func initDefaultTitleBody(ctx CreateContext, state *shared.IssueMetadataState, useFirstCommit bool, addBody bool) error { |
| 646 | commits, err := ctx.GitClient.Commits(context.Background(), ctx.BaseTrackingBranch, ctx.PRRefs.UnqualifiedHeadRef()) |
| 647 | if err != nil { |
| 648 | return err |
| 649 | } |
| 650 | |
| 651 | if len(commits) == 1 || useFirstCommit { |
| 652 | state.Title = commits[len(commits)-1].Title |
| 653 | state.Body = commits[len(commits)-1].Body |
| 654 | } else { |
| 655 | state.Title = humanize(ctx.PRRefs.UnqualifiedHeadRef()) |
| 656 | var body strings.Builder |
| 657 | for i := len(commits) - 1; i >= 0; i-- { |
| 658 | fmt.Fprintf(&body, "- **%s**\n", commits[i].Title) |
| 659 | if addBody { |
| 660 | x := regexPattern.ReplaceAllString(commits[i].Body, " ") |
| 661 | fmt.Fprintf(&body, "%s", x) |
| 662 | |
| 663 | if i > 0 { |
| 664 | fmt.Fprintln(&body) |
| 665 | fmt.Fprintln(&body) |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | state.Body = body.String() |
| 670 | } |
| 671 | |
| 672 | return nil |
| 673 | } |
| 674 | |
| 675 | func NewIssueState(ctx CreateContext, opts CreateOptions, apiActorsSupported bool) (*shared.IssueMetadataState, error) { |
| 676 | var milestoneTitles []string |
no test coverage detected