| 248 | } |
| 249 | |
| 250 | func editRun(opts *EditOptions) error { |
| 251 | httpClient, err := opts.HttpClient() |
| 252 | if err != nil { |
| 253 | return err |
| 254 | } |
| 255 | |
| 256 | baseRepo, err := opts.BaseRepo() |
| 257 | if err != nil { |
| 258 | return err |
| 259 | } |
| 260 | |
| 261 | // Prompt the user which fields they'd like to edit. |
| 262 | editable := opts.Editable |
| 263 | editable.IssueType.Selectable = true |
| 264 | if opts.Interactive { |
| 265 | err = opts.FieldsToEditSurvey(opts.Prompter, &editable) |
| 266 | if err != nil { |
| 267 | return err |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | if opts.Detector == nil { |
| 272 | cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24) |
| 273 | opts.Detector = fd.NewDetector(cachedClient, baseRepo.RepoHost()) |
| 274 | } |
| 275 | |
| 276 | issueFeatures, err := opts.Detector.IssueFeatures() |
| 277 | if err != nil { |
| 278 | return err |
| 279 | } |
| 280 | |
| 281 | lookupFields := []string{"id", "number", "title", "body", "url"} |
| 282 | if editable.Assignees.Edited { |
| 283 | // TODO ApiActorsSupported |
| 284 | if issueFeatures.ApiActorsSupported { |
| 285 | editable.ApiActorsSupported = true |
| 286 | lookupFields = append(lookupFields, "assignedActors") |
| 287 | } else { |
| 288 | lookupFields = append(lookupFields, "assignees") |
| 289 | } |
| 290 | } |
| 291 | if editable.Labels.Edited { |
| 292 | lookupFields = append(lookupFields, "labels") |
| 293 | } |
| 294 | if editable.Projects.Edited { |
| 295 | // TODO projectsV1Deprecation |
| 296 | // Remove this section as we should no longer add projectCards |
| 297 | projectsV1Support := opts.Detector.ProjectsV1() |
| 298 | if projectsV1Support == gh.ProjectsV1Supported { |
| 299 | lookupFields = append(lookupFields, "projectCards") |
| 300 | } |
| 301 | |
| 302 | lookupFields = append(lookupFields, "projectItems") |
| 303 | } |
| 304 | if editable.Milestone.Edited { |
| 305 | lookupFields = append(lookupFields, "milestone") |
| 306 | } |
| 307 | if editable.IssueType.Edited { |