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

Function NewIssueState

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

Source from the content-addressed store, hash-verified

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