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