| 291 | } |
| 292 | |
| 293 | func 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 { |