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

Function editRun

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

Source from the content-addressed store, hash-verified

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