Skip to content

Commit 0faf4b0

Browse files
BagToadCopilot
andauthored
Clean up deferred issue update helper (cli#13584)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7ef9c54 commit 0faf4b0

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

pkg/cmd/issue/create/create.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ func deferredUpdateIssueOptions(client *api.Client, baseRepo ghrepo.Interface, i
449449
var err error
450450
typeID, err = issueShared.ResolveIssueTypeName(client, baseRepo, opts.IssueType)
451451
if err != nil {
452-
return updateOpts, err
452+
return api.DeferredUpdateIssueOptions{}, err
453453
}
454454
}
455455
updateOpts.IssueTypeID = typeID
@@ -458,23 +458,23 @@ func deferredUpdateIssueOptions(client *api.Client, baseRepo ghrepo.Interface, i
458458
if opts.Parent != "" {
459459
parentID, err := issueShared.ResolveIssueRef(client, baseRepo, opts.Parent)
460460
if err != nil {
461-
return updateOpts, fmt.Errorf("resolving --parent reference %q: %w", opts.Parent, err)
461+
return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --parent reference %q: %w", opts.Parent, err)
462462
}
463463
updateOpts.ParentID = parentID
464464
}
465465

466466
for _, ref := range opts.BlockedBy {
467467
id, err := issueShared.ResolveIssueRef(client, baseRepo, ref)
468468
if err != nil {
469-
return updateOpts, fmt.Errorf("resolving --blocked-by reference %q: %w", ref, err)
469+
return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --blocked-by reference %q: %w", ref, err)
470470
}
471471
updateOpts.AddBlockedByIDs = append(updateOpts.AddBlockedByIDs, id)
472472
}
473473

474474
for _, ref := range opts.Blocking {
475475
id, err := issueShared.ResolveIssueRef(client, baseRepo, ref)
476476
if err != nil {
477-
return updateOpts, fmt.Errorf("resolving --blocking reference %q: %w", ref, err)
477+
return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --blocking reference %q: %w", ref, err)
478478
}
479479
updateOpts.AddBlockingIDs = append(updateOpts.AddBlockingIDs, id)
480480
}

pkg/cmd/issue/edit/edit.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Comman
185185
opts.Editable.IssueType.Edited = true
186186
}
187187

188+
// hasDeferredFlags covers edit flags that flow through the
189+
// deferred update path rather than the prShared.Editable struct,
190+
// so they would otherwise be invisible to Editable.Dirty() below.
191+
// Note that --type (set) is intentionally absent: it lights up
192+
// opts.Editable.IssueType.Edited above, which Editable.Dirty()
193+
// already picks up. Only --remove-type needs to be listed here.
188194
hasDeferredFlags := opts.RemoveIssueType ||
189195
flags.Changed("parent") || opts.RemoveParent ||
190196
len(opts.AddSubIssues) > 0 || len(opts.RemoveSubIssues) > 0 ||
@@ -482,52 +488,52 @@ func deferredUpdateIssueOptions(client *api.Client, baseRepo ghrepo.Interface, i
482488
} else if editOpts.Parent != "" {
483489
parentID, err := issueShared.ResolveIssueRef(client, baseRepo, editOpts.Parent)
484490
if err != nil {
485-
return updateOpts, fmt.Errorf("resolving --parent reference %q: %w", editOpts.Parent, err)
491+
return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --parent reference %q: %w", editOpts.Parent, err)
486492
}
487493
updateOpts.ParentID = parentID
488494
}
489495

490496
for _, ref := range editOpts.AddSubIssues {
491497
id, err := issueShared.ResolveIssueRef(client, baseRepo, ref)
492498
if err != nil {
493-
return updateOpts, fmt.Errorf("resolving --add-sub-issue reference %q: %w", ref, err)
499+
return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --add-sub-issue reference %q: %w", ref, err)
494500
}
495501
updateOpts.AddSubIssueIDs = append(updateOpts.AddSubIssueIDs, id)
496502
}
497503
for _, ref := range editOpts.RemoveSubIssues {
498504
id, err := issueShared.ResolveIssueRef(client, baseRepo, ref)
499505
if err != nil {
500-
return updateOpts, fmt.Errorf("resolving --remove-sub-issue reference %q: %w", ref, err)
506+
return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --remove-sub-issue reference %q: %w", ref, err)
501507
}
502508
updateOpts.RemoveSubIssueIDs = append(updateOpts.RemoveSubIssueIDs, id)
503509
}
504510

505511
for _, ref := range editOpts.AddBlockedBy {
506512
id, err := issueShared.ResolveIssueRef(client, baseRepo, ref)
507513
if err != nil {
508-
return updateOpts, fmt.Errorf("resolving --add-blocked-by reference %q: %w", ref, err)
514+
return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --add-blocked-by reference %q: %w", ref, err)
509515
}
510516
updateOpts.AddBlockedByIDs = append(updateOpts.AddBlockedByIDs, id)
511517
}
512518
for _, ref := range editOpts.RemoveBlockedBy {
513519
id, err := issueShared.ResolveIssueRef(client, baseRepo, ref)
514520
if err != nil {
515-
return updateOpts, fmt.Errorf("resolving --remove-blocked-by reference %q: %w", ref, err)
521+
return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --remove-blocked-by reference %q: %w", ref, err)
516522
}
517523
updateOpts.RemoveBlockedByIDs = append(updateOpts.RemoveBlockedByIDs, id)
518524
}
519525

520526
for _, ref := range editOpts.AddBlocking {
521527
id, err := issueShared.ResolveIssueRef(client, baseRepo, ref)
522528
if err != nil {
523-
return updateOpts, fmt.Errorf("resolving --add-blocking reference %q: %w", ref, err)
529+
return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --add-blocking reference %q: %w", ref, err)
524530
}
525531
updateOpts.AddBlockingIDs = append(updateOpts.AddBlockingIDs, id)
526532
}
527533
for _, ref := range editOpts.RemoveBlocking {
528534
id, err := issueShared.ResolveIssueRef(client, baseRepo, ref)
529535
if err != nil {
530-
return updateOpts, fmt.Errorf("resolving --remove-blocking reference %q: %w", ref, err)
536+
return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --remove-blocking reference %q: %w", ref, err)
531537
}
532538
updateOpts.RemoveBlockingIDs = append(updateOpts.RemoveBlockingIDs, id)
533539
}

0 commit comments

Comments
 (0)