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

Function editRun

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

Source from the content-addressed store, hash-verified

288}
289
290func editRun(opts *EditOptions) error {
291 httpClient, err := opts.HttpClient()
292 if err != nil {
293 return err
294 }
295
296 baseRepo, err := opts.BaseRepo()
297 if err != nil {
298 return err
299 }
300
301 // Prompt the user which fields they'd like to edit.
302 editable := opts.Editable
303 editable.IssueType.Selectable = true
304 if opts.Interactive {
305 err = opts.FieldsToEditSurvey(opts.Prompter, &editable)
306 if err != nil {
307 return err
308 }
309 }
310
311 if opts.Detector == nil {
312 cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
313 opts.Detector = fd.NewDetector(cachedClient, baseRepo.RepoHost())
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 {

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