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

Function createRun

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

Source from the content-addressed store, hash-verified

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

Callers 4

Test_createRunFunction · 0.70
NewCmdCreateFunction · 0.70

Calls 15

ReplaceSliceMethod · 0.95
HasMetadataMethod · 0.95
AuthenticationMethod · 0.95
BodyMethod · 0.95
NameForSubmitMethod · 0.95
TitleMethod · 0.95
UploadAndAttachMethod · 0.95
NewClientFromHTTPFunction · 0.92
NewCachedHTTPClientFunction · 0.92
NewStringSetFunction · 0.92
GenerateRepoURLFunction · 0.92
DisplayURLFunction · 0.92

Tested by 3

Test_createRunFunction · 0.56