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