| 473 | } |
| 474 | |
| 475 | func deferredUpdateIssueOptions(client *api.Client, baseRepo ghrepo.Interface, issue *api.Issue, editOpts *EditOptions, issueTypeID string) (api.DeferredUpdateIssueOptions, error) { |
| 476 | updateOpts := api.DeferredUpdateIssueOptions{ |
| 477 | IssueID: issue.ID, |
| 478 | Hostname: baseRepo.RepoHost(), |
| 479 | IssueTypeID: issueTypeID, |
| 480 | RemoveIssueType: editOpts.RemoveIssueType, |
| 481 | ReplaceExistingParent: true, |
| 482 | } |
| 483 | |
| 484 | if editOpts.RemoveParent { |
| 485 | if issue.Parent != nil { |
| 486 | updateOpts.RemoveParentID = issue.Parent.ID |
| 487 | } |
| 488 | } else if editOpts.Parent != "" { |
| 489 | parentID, err := issueShared.ResolveIssueRef(client, baseRepo, editOpts.Parent) |
| 490 | if err != nil { |
| 491 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --parent reference %q: %w", editOpts.Parent, err) |
| 492 | } |
| 493 | updateOpts.ParentID = parentID |
| 494 | } |
| 495 | |
| 496 | for _, ref := range editOpts.AddSubIssues { |
| 497 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 498 | if err != nil { |
| 499 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --add-sub-issue reference %q: %w", ref, err) |
| 500 | } |
| 501 | updateOpts.AddSubIssueIDs = append(updateOpts.AddSubIssueIDs, id) |
| 502 | } |
| 503 | for _, ref := range editOpts.RemoveSubIssues { |
| 504 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 505 | if err != nil { |
| 506 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --remove-sub-issue reference %q: %w", ref, err) |
| 507 | } |
| 508 | updateOpts.RemoveSubIssueIDs = append(updateOpts.RemoveSubIssueIDs, id) |
| 509 | } |
| 510 | |
| 511 | for _, ref := range editOpts.AddBlockedBy { |
| 512 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 513 | if err != nil { |
| 514 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --add-blocked-by reference %q: %w", ref, err) |
| 515 | } |
| 516 | updateOpts.AddBlockedByIDs = append(updateOpts.AddBlockedByIDs, id) |
| 517 | } |
| 518 | for _, ref := range editOpts.RemoveBlockedBy { |
| 519 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 520 | if err != nil { |
| 521 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --remove-blocked-by reference %q: %w", ref, err) |
| 522 | } |
| 523 | updateOpts.RemoveBlockedByIDs = append(updateOpts.RemoveBlockedByIDs, id) |
| 524 | } |
| 525 | |
| 526 | for _, ref := range editOpts.AddBlocking { |
| 527 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 528 | if err != nil { |
| 529 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --add-blocking reference %q: %w", ref, err) |
| 530 | } |
| 531 | updateOpts.AddBlockingIDs = append(updateOpts.AddBlockingIDs, id) |
| 532 | } |