| 288 | } |
| 289 | |
| 290 | func 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 { |