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

Function createRun

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

Source from the content-addressed store, hash-verified

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