MCPcopy
hub / github.com/cli/cli / NewIssueState

Function NewIssueState

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

Source from the content-addressed store, hash-verified

673}
674
675func NewIssueState(ctx CreateContext, opts CreateOptions, apiActorsSupported bool) (*shared.IssueMetadataState, error) {
676 var milestoneTitles []string
677 if opts.Milestone != "" {
678 milestoneTitles = []string{opts.Milestone}
679 }
680
681 assigneeReplacer := shared.NewSpecialAssigneeReplacer(ctx.Client, ctx.PRRefs.BaseRepo().RepoHost(), apiActorsSupported, !opts.WebMode)
682 assignees, err := assigneeReplacer.ReplaceSlice(opts.Assignees)
683 if err != nil {
684 return nil, err
685 }
686
687 copilotReplacer := shared.NewCopilotReviewerReplacer()
688 reviewers := copilotReplacer.ReplaceSlice(opts.Reviewers)
689
690 state := &shared.IssueMetadataState{
691 Type: shared.PRMetadata,
692 Reviewers: reviewers,
693 Assignees: assignees,
694 Labels: opts.Labels,
695 ProjectTitles: opts.Projects,
696 Milestones: milestoneTitles,
697 Draft: opts.IsDraft,
698 }
699
700 if opts.FillVerbose || opts.Autofill || opts.FillFirst || !opts.TitleProvided || !opts.BodyProvided {
701 err := initDefaultTitleBody(ctx, state, opts.FillFirst, opts.FillVerbose)
702 if err != nil && (opts.FillVerbose || opts.Autofill || opts.FillFirst) {
703 return nil, fmt.Errorf("could not compute title or body defaults: %w", err)
704 }
705 }
706
707 return state, nil
708}
709
710func NewCreateContext(opts *CreateOptions) (*CreateContext, error) {
711 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