(ctx CreateContext, state *shared.IssueMetadataState, useFirstCommit bool, addBody bool)
| 706 | var regexPattern = regexp.MustCompile(`(?m)^`) |
| 707 | |
| 708 | func initDefaultTitleBody(ctx CreateContext, state *shared.IssueMetadataState, useFirstCommit bool, addBody bool) error { |
| 709 | commits, err := ctx.GitClient.Commits(context.Background(), ctx.BaseTrackingBranch, ctx.PRRefs.UnqualifiedHeadRef()) |
| 710 | if err != nil { |
| 711 | return err |
| 712 | } |
| 713 | |
| 714 | if len(commits) == 1 || useFirstCommit { |
| 715 | state.Title = commits[len(commits)-1].Title |
| 716 | state.Body = commits[len(commits)-1].Body |
| 717 | } else { |
| 718 | state.Title = humanize(ctx.PRRefs.UnqualifiedHeadRef()) |
| 719 | var body strings.Builder |
| 720 | for i := len(commits) - 1; i >= 0; i-- { |
| 721 | fmt.Fprintf(&body, "- **%s**\n", commits[i].Title) |
| 722 | if addBody { |
| 723 | x := regexPattern.ReplaceAllString(commits[i].Body, " ") |
| 724 | fmt.Fprintf(&body, "%s", x) |
| 725 | |
| 726 | if i > 0 { |
| 727 | fmt.Fprintln(&body) |
| 728 | fmt.Fprintln(&body) |
| 729 | } |
| 730 | } |
| 731 | } |
| 732 | state.Body = body.String() |
| 733 | } |
| 734 | |
| 735 | return nil |
| 736 | } |
| 737 | |
| 738 | func NewIssueState(ctx CreateContext, opts CreateOptions, apiActorsSupported bool) (*shared.IssueMetadataState, error) { |
| 739 | var milestoneTitles []string |
no test coverage detected