MCPcopy Create free account
hub / github.com/cli/cli / NewIssueState

Function NewIssueState

pkg/cmd/pr/create/create.go:735–768  ·  view source on GitHub ↗
(ctx CreateContext, opts CreateOptions, apiActorsSupported bool)

Source from the content-addressed store, hash-verified

733}
734
735func NewIssueState(ctx CreateContext, opts CreateOptions, apiActorsSupported bool) (*shared.IssueMetadataState, error) {
736 var milestoneTitles []string
737 if opts.Milestone != "" {
738 milestoneTitles = []string{opts.Milestone}
739 }
740
741 assigneeReplacer := shared.NewSpecialAssigneeReplacer(ctx.Client, ctx.PRRefs.BaseRepo().RepoHost(), apiActorsSupported, !opts.WebMode)
742 assignees, err := assigneeReplacer.ReplaceSlice(opts.Assignees)
743 if err != nil {
744 return nil, err
745 }
746
747 copilotReplacer := shared.NewCopilotReviewerReplacer()
748 reviewers := copilotReplacer.ReplaceSlice(opts.Reviewers)
749
750 state := &shared.IssueMetadataState{
751 Type: shared.PRMetadata,
752 Reviewers: reviewers,
753 Assignees: assignees,
754 Labels: opts.Labels,
755 ProjectTitles: opts.Projects,
756 Milestones: milestoneTitles,
757 Draft: opts.IsDraft,
758 }
759
760 if opts.FillVerbose || opts.Autofill || opts.FillFirst || !opts.TitleProvided || !opts.BodyProvided {
761 err := initDefaultTitleBody(ctx, state, opts.FillFirst, opts.FillVerbose)
762 if err != nil && (opts.FillVerbose || opts.Autofill || opts.FillFirst) {
763 return nil, fmt.Errorf("could not compute title or body defaults: %w", err)
764 }
765 }
766
767 return state, nil
768}
769
770func NewCreateContext(opts *CreateOptions) (*CreateContext, error) {
771 httpClient, err := opts.HttpClient()

Callers 1

createRunFunction · 0.85

Calls 8

ReplaceSliceMethod · 0.95
initDefaultTitleBodyFunction · 0.85
RepoHostMethod · 0.65
BaseRepoMethod · 0.65
ErrorfMethod · 0.65
ReplaceSliceMethod · 0.45

Tested by

no test coverage detected