Rename --set-parent to --parent for milestone-style symmetry
The --milestone / --remove-milestone pair has long been the established pattern for value-takes-or-removes flag pairs in gh issue edit. Bring --set-parent into line as --parent / --remove-parent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
e87ccc5fca
commit
5c783a229b
2 changed files with 18 additions and 18 deletions
|
|
@ -36,7 +36,7 @@ type EditOptions struct {
|
|||
IssueNumbers []int
|
||||
Interactive bool
|
||||
|
||||
SetParent string
|
||||
Parent string
|
||||
RemoveParent bool
|
||||
AddSubIssues []string
|
||||
RemoveSubIssues []string
|
||||
|
|
@ -87,7 +87,7 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Comman
|
|||
$ gh issue edit 23 --body-file body.txt
|
||||
$ gh issue edit 23 34 --add-label "help wanted"
|
||||
$ gh issue edit 23 --type Bug
|
||||
$ gh issue edit 23 --set-parent 100
|
||||
$ gh issue edit 23 --parent 100
|
||||
$ gh issue edit 23 --remove-parent
|
||||
$ gh issue edit 100 --add-sub-issue 123,124
|
||||
$ gh issue edit 123 --add-blocked-by 200 --add-blocking 300,301
|
||||
|
|
@ -143,8 +143,8 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Comman
|
|||
}
|
||||
|
||||
if err := cmdutil.MutuallyExclusive(
|
||||
"specify only one of --set-parent or --remove-parent",
|
||||
flags.Changed("set-parent"),
|
||||
"specify only one of --parent or --remove-parent",
|
||||
flags.Changed("parent"),
|
||||
opts.RemoveParent,
|
||||
); err != nil {
|
||||
return err
|
||||
|
|
@ -174,7 +174,7 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Comman
|
|||
opts.Editable.IssueType.Edited = true
|
||||
}
|
||||
|
||||
hasRelationshipFlags := flags.Changed("set-parent") || opts.RemoveParent ||
|
||||
hasRelationshipFlags := flags.Changed("parent") || opts.RemoveParent ||
|
||||
len(opts.AddSubIssues) > 0 || len(opts.RemoveSubIssues) > 0 ||
|
||||
len(opts.AddBlockedBy) > 0 || len(opts.RemoveBlockedBy) > 0 ||
|
||||
len(opts.AddBlocking) > 0 || len(opts.RemoveBlocking) > 0
|
||||
|
|
@ -216,7 +216,7 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Comman
|
|||
cmd.Flags().StringVarP(&opts.Editable.Milestone.Value, "milestone", "m", "", "Edit the milestone the issue belongs to by `name`")
|
||||
cmd.Flags().BoolVar(&removeMilestone, "remove-milestone", false, "Remove the milestone association from the issue")
|
||||
cmd.Flags().StringVar(&opts.Editable.IssueType.Value, "type", "", "Set the issue type by `name`")
|
||||
cmd.Flags().StringVar(&opts.SetParent, "set-parent", "", "Set the parent issue by `number` or URL")
|
||||
cmd.Flags().StringVar(&opts.Parent, "parent", "", "Set the parent issue by `number` or URL")
|
||||
cmd.Flags().BoolVar(&opts.RemoveParent, "remove-parent", false, "Remove the parent issue")
|
||||
cmd.Flags().StringSliceVar(&opts.AddSubIssues, "add-sub-issue", nil, "Add sub-issues by `number` or URL")
|
||||
cmd.Flags().StringSliceVar(&opts.RemoveSubIssues, "remove-sub-issue", nil, "Remove sub-issues by `number` or URL")
|
||||
|
|
@ -288,7 +288,7 @@ func editRun(opts *EditOptions) error {
|
|||
if editable.IssueType.Edited {
|
||||
lookupFields = append(lookupFields, "issueType")
|
||||
}
|
||||
if opts.SetParent != "" || opts.RemoveParent {
|
||||
if opts.Parent != "" || opts.RemoveParent {
|
||||
lookupFields = append(lookupFields, "parent")
|
||||
}
|
||||
|
||||
|
|
@ -465,10 +465,10 @@ func deferredUpdateIssueOptions(client *api.Client, baseRepo ghrepo.Interface, i
|
|||
if issue.Parent != nil {
|
||||
updateOpts.RemoveParentID = issue.Parent.ID
|
||||
}
|
||||
} else if editOpts.SetParent != "" {
|
||||
parentID, err := issueShared.ResolveIssueRef(client, baseRepo, editOpts.SetParent)
|
||||
} else if editOpts.Parent != "" {
|
||||
parentID, err := issueShared.ResolveIssueRef(client, baseRepo, editOpts.Parent)
|
||||
if err != nil {
|
||||
return updateOpts, fmt.Errorf("resolving --set-parent reference %q: %w", editOpts.SetParent, err)
|
||||
return updateOpts, fmt.Errorf("resolving --parent reference %q: %w", editOpts.Parent, err)
|
||||
}
|
||||
updateOpts.ParentID = parentID
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,11 +298,11 @@ func TestNewCmdEdit(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "set-parent flag",
|
||||
input: "23 --set-parent 100",
|
||||
name: "parent flag",
|
||||
input: "23 --parent 100",
|
||||
output: EditOptions{
|
||||
IssueNumbers: []int{23},
|
||||
SetParent: "100",
|
||||
Parent: "100",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -314,8 +314,8 @@ func TestNewCmdEdit(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "both set-parent and remove-parent flags",
|
||||
input: "23 --set-parent 100 --remove-parent",
|
||||
name: "both parent and remove-parent flags",
|
||||
input: "23 --parent 100 --remove-parent",
|
||||
wantsErr: true,
|
||||
},
|
||||
{
|
||||
|
|
@ -412,7 +412,7 @@ func TestNewCmdEdit(t *testing.T) {
|
|||
assert.Equal(t, tt.output.IssueNumbers, gotOpts.IssueNumbers)
|
||||
assert.Equal(t, tt.output.Interactive, gotOpts.Interactive)
|
||||
assert.Equal(t, tt.output.Editable, gotOpts.Editable)
|
||||
assert.Equal(t, tt.output.SetParent, gotOpts.SetParent)
|
||||
assert.Equal(t, tt.output.Parent, gotOpts.Parent)
|
||||
assert.Equal(t, tt.output.RemoveParent, gotOpts.RemoveParent)
|
||||
assert.Equal(t, tt.output.AddSubIssues, gotOpts.AddSubIssues)
|
||||
assert.Equal(t, tt.output.RemoveSubIssues, gotOpts.RemoveSubIssues)
|
||||
|
|
@ -907,7 +907,7 @@ func Test_editRun(t *testing.T) {
|
|||
Detector: &fd.EnabledDetectorMock{},
|
||||
IssueNumbers: []int{123},
|
||||
Interactive: false,
|
||||
SetParent: "100",
|
||||
Parent: "100",
|
||||
FetchOptions: func(_ *api.Client, _ ghrepo.Interface, _ *prShared.Editable, _ gh.ProjectsV1Support) error {
|
||||
return nil
|
||||
},
|
||||
|
|
@ -1436,7 +1436,7 @@ func Test_editRun_crossHostRelationshipRefs(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "set parent",
|
||||
input: &EditOptions{SetParent: crossHostURL},
|
||||
input: &EditOptions{Parent: crossHostURL},
|
||||
},
|
||||
{
|
||||
name: "add sub-issue",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue