| 563 | } |
| 564 | |
| 565 | func deferredUpdateIssueOptions(client *api.Client, baseRepo ghrepo.Interface, issue *api.Issue, editOpts *EditOptions, issueTypeID string) (api.DeferredUpdateIssueOptions, error) { |
| 566 | updateOpts := api.DeferredUpdateIssueOptions{ |
| 567 | IssueID: issue.ID, |
| 568 | Hostname: baseRepo.RepoHost(), |
| 569 | IssueTypeID: issueTypeID, |
| 570 | RemoveIssueType: editOpts.RemoveIssueType, |
| 571 | ReplaceExistingParent: true, |
| 572 | } |
| 573 | |
| 574 | if editOpts.RemoveParent { |
| 575 | if issue.Parent != nil { |
| 576 | updateOpts.RemoveParentID = issue.Parent.ID |
| 577 | } |
| 578 | } else if editOpts.Parent != "" { |
| 579 | parentID, err := issueShared.ResolveIssueRef(client, baseRepo, editOpts.Parent) |
| 580 | if err != nil { |
| 581 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --parent reference %q: %w", editOpts.Parent, err) |
| 582 | } |
| 583 | updateOpts.ParentID = parentID |
| 584 | } |
| 585 | |
| 586 | for _, ref := range editOpts.AddSubIssues { |
| 587 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 588 | if err != nil { |
| 589 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --add-sub-issue reference %q: %w", ref, err) |
| 590 | } |
| 591 | updateOpts.AddSubIssueIDs = append(updateOpts.AddSubIssueIDs, id) |
| 592 | } |
| 593 | for _, ref := range editOpts.RemoveSubIssues { |
| 594 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 595 | if err != nil { |
| 596 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --remove-sub-issue reference %q: %w", ref, err) |
| 597 | } |
| 598 | updateOpts.RemoveSubIssueIDs = append(updateOpts.RemoveSubIssueIDs, id) |
| 599 | } |
| 600 | |
| 601 | for _, ref := range editOpts.AddBlockedBy { |
| 602 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 603 | if err != nil { |
| 604 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --add-blocked-by reference %q: %w", ref, err) |
| 605 | } |
| 606 | updateOpts.AddBlockedByIDs = append(updateOpts.AddBlockedByIDs, id) |
| 607 | } |
| 608 | for _, ref := range editOpts.RemoveBlockedBy { |
| 609 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 610 | if err != nil { |
| 611 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --remove-blocked-by reference %q: %w", ref, err) |
| 612 | } |
| 613 | updateOpts.RemoveBlockedByIDs = append(updateOpts.RemoveBlockedByIDs, id) |
| 614 | } |
| 615 | |
| 616 | for _, ref := range editOpts.AddBlocking { |
| 617 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 618 | if err != nil { |
| 619 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --add-blocking reference %q: %w", ref, err) |
| 620 | } |
| 621 | updateOpts.AddBlockingIDs = append(updateOpts.AddBlockingIDs, id) |
| 622 | } |