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

Function editRun

pkg/cmd/issue/edit/edit.go:291–547  ·  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 opts.Detector = fd.NewCachedDetector(httpClient, baseRepo.RepoHost(), time.Hour*24)
314 }
315
316 issueFeatures, err := opts.Detector.IssueFeatures()
317 if err != nil {
318 return err
319 }
320
321 lookupFields := []string{"id", "number", "title", "body", "url"}
322 if editable.Assignees.Edited {
323 // TODO ApiActorsSupported
324 if issueFeatures.ApiActorsSupported {
325 editable.ApiActorsSupported = true
326 lookupFields = append(lookupFields, "assignedActors")
327 } else {
328 lookupFields = append(lookupFields, "assignees")
329 }
330 }
331 if editable.Labels.Edited {
332 lookupFields = append(lookupFields, "labels")
333 }
334 if editable.Projects.Edited {
335 // TODO projectsV1Deprecation
336 // Remove this section as we should no longer add projectCards
337 projectsV1Support := opts.Detector.ProjectsV1()
338 if projectsV1Support == gh.ProjectsV1Supported {
339 lookupFields = append(lookupFields, "projectCards")
340 }
341
342 lookupFields = append(lookupFields, "projectItems")
343 }
344 if editable.Milestone.Edited {
345 lookupFields = append(lookupFields, "milestone")
346 }
347 if editable.IssueType.Edited {
348 lookupFields = append(lookupFields, "issueType")

Callers 5

Test_editRunFunction · 0.70
TestApiActorsSupportedFunction · 0.70
NewCmdEditFunction · 0.70

Calls 15

UploadAndAttachMethod · 0.95
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
hasDeferredEditsMethod · 0.80

Tested by 4

Test_editRunFunction · 0.56
TestApiActorsSupportedFunction · 0.56