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