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

Function editRun

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

Source from the content-addressed store, hash-verified

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