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

Function editRun

pkg/cmd/issue/edit/edit.go:291–548  ·  view source on GitHub ↗
(opts *EditOptions)

Source from the content-addressed store, hash-verified

289}
290
291func editRun(opts *EditOptions) error {
292 httpClient, err := opts.HttpClient()
293 if err != nil {
294 return err
295 }
296
297 baseRepo, err := opts.BaseRepo()
298 if err != nil {
299 return err
300 }
301
302 // Prompt the user which fields they'd like to edit.
303 editable := opts.Editable
304 editable.IssueType.Selectable = true
305 if opts.Interactive {
306 err = opts.FieldsToEditSurvey(opts.Prompter, &editable)
307 if err != nil {
308 return err
309 }
310 }
311
312 if opts.Detector == nil {
313 cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
314 opts.Detector = fd.NewDetector(cachedClient, baseRepo.RepoHost())
315 }
316
317 issueFeatures, err := opts.Detector.IssueFeatures()
318 if err != nil {
319 return err
320 }
321
322 lookupFields := []string{"id", "number", "title", "body", "url"}
323 if editable.Assignees.Edited {
324 // TODO ApiActorsSupported
325 if issueFeatures.ApiActorsSupported {
326 editable.ApiActorsSupported = true
327 lookupFields = append(lookupFields, "assignedActors")
328 } else {
329 lookupFields = append(lookupFields, "assignees")
330 }
331 }
332 if editable.Labels.Edited {
333 lookupFields = append(lookupFields, "labels")
334 }
335 if editable.Projects.Edited {
336 // TODO projectsV1Deprecation
337 // Remove this section as we should no longer add projectCards
338 projectsV1Support := opts.Detector.ProjectsV1()
339 if projectsV1Support == gh.ProjectsV1Supported {
340 lookupFields = append(lookupFields, "projectCards")
341 }
342
343 lookupFields = append(lookupFields, "projectItems")
344 }
345 if editable.Milestone.Edited {
346 lookupFields = append(lookupFields, "milestone")
347 }
348 if editable.IssueType.Edited {

Callers 5

Test_editRunFunction · 0.70
TestApiActorsSupportedFunction · 0.70
NewCmdEditFunction · 0.70

Calls 15

UploadAndAttachMethod · 0.95
NewCachedHTTPClientFunction · 0.92
NewUploaderFunction · 0.92
NewClientFromHTTPFunction · 0.92
DeferredUpdateIssueFunction · 0.92
PluralizeFunction · 0.92
lookupIssueTypeIDFunction · 0.85
RecordOperationsMethod · 0.80
NamesMethod · 0.80
ProjectNamesMethod · 0.80
ProjectTitlesMethod · 0.80
DirtyMethod · 0.80

Tested by 4

Test_editRunFunction · 0.56
TestApiActorsSupportedFunction · 0.56