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

Function NewIssueState

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

Source from the content-addressed store, hash-verified

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