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

Function createRun

pkg/cmd/issue/create/create.go:200–492  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

198}
199
200func createRun(opts *CreateOptions) (err error) {
201 httpClient, err := opts.HttpClient()
202 if err != nil {
203 return
204 }
205 apiClient := api.NewClientFromHTTP(httpClient)
206
207 baseRepo, err := opts.BaseRepo()
208 if err != nil {
209 return
210 }
211
212 // TODO projectsV1Deprecation
213 // Remove this section as we should no longer need to detect
214 if opts.Detector == nil {
215 opts.Detector = fd.NewCachedDetector(httpClient, baseRepo.RepoHost(), time.Hour*24)
216 }
217
218 projectsV1Support := opts.Detector.ProjectsV1()
219 issueFeatures, err := opts.Detector.IssueFeatures()
220 if err != nil {
221 return err
222 }
223
224 isTerminal := opts.IO.IsStdoutTTY()
225
226 var milestones []string
227 if opts.Milestone != "" {
228 milestones = []string{opts.Milestone}
229 }
230
231 // Replace special values in assignees
232 // For web mode, @copilot should be replaced by name; otherwise, login.
233 assigneeReplacer := prShared.NewSpecialAssigneeReplacer(apiClient, baseRepo.RepoHost(), issueFeatures.ApiActorsSupported, !opts.WebMode)
234 assignees, err := assigneeReplacer.ReplaceSlice(opts.Assignees)
235 if err != nil {
236 return err
237 }
238 assigneeSet := set.NewStringSet()
239 assigneeSet.AddValues(assignees)
240
241 tb := prShared.IssueMetadataState{
242 Type: prShared.IssueMetadata,
243 ApiActorsSupported: issueFeatures.ApiActorsSupported, // TODO ApiActorsSupported
244 Assignees: assigneeSet.ToSlice(),
245 Labels: opts.Labels,
246 ProjectTitles: opts.Projects,
247 Milestones: milestones,
248 Title: opts.Title,
249 Body: opts.Body,
250 }
251
252 if opts.RecoverFile != "" {
253 err = prShared.FillFromJSON(opts.IO, opts.RecoverFile, &tb)
254 if err != nil {
255 err = fmt.Errorf("failed to recover input: %w", err)
256 return
257 }

Callers 4

Test_createRunFunction · 0.70
NewCmdCreateFunction · 0.70

Calls 15

ReplaceSliceMethod · 0.95
HasMetadataMethod · 0.95
BodyMethod · 0.95
NameForSubmitMethod · 0.95
TitleMethod · 0.95
UploadAndAttachMethod · 0.95
NewClientFromHTTPFunction · 0.92
NewStringSetFunction · 0.92
GenerateRepoURLFunction · 0.92
DisplayURLFunction · 0.92
FullNameFunction · 0.92
IssueRepoInfoFunction · 0.92

Tested by 3

Test_createRunFunction · 0.56