Add --remove-type flag to gh issue edit

Pair --type with --remove-type so callers can clear an issue's type
without going through the interactive editor, mirroring the
--milestone / --remove-milestone and --parent / --remove-parent
patterns. The two type flags are mutually exclusive.

UpdateIssueIssueType now sends a null issueTypeId when the caller
passes an empty string, which is what the API requires to clear the
field. The orchestrator fires the mutation when either IssueTypeID is
non-empty or RemoveIssueType is set.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Kynan Ware 2026-05-12 20:28:56 -06:00
parent eb7397695f
commit 6bbe6e5bac
3 changed files with 66 additions and 8 deletions

View file

@ -297,6 +297,19 @@ func TestNewCmdEdit(t *testing.T) {
},
},
},
{
name: "remove-type flag",
input: "23 --remove-type",
output: EditOptions{
IssueNumbers: []int{23},
RemoveIssueType: true,
},
},
{
name: "both type and remove-type flags",
input: "23 --type Bug --remove-type",
wantsErr: true,
},
{
name: "parent flag",
input: "23 --parent 100",
@ -855,6 +868,29 @@ func Test_editRun(t *testing.T) {
},
stdout: "https://github.com/OWNER/REPO/issue/123\n",
},
{
name: "remove type",
input: &EditOptions{
Detector: &fd.EnabledDetectorMock{},
IssueNumbers: []int{123},
Interactive: false,
RemoveIssueType: true,
FetchOptions: prShared.FetchOptions,
},
httpStubs: func(t *testing.T, reg *httpmock.Registry) {
mockIssueGet(t, reg)
reg.Register(
httpmock.GraphQL(`mutation UpdateIssueIssueType\b`),
httpmock.GraphQLMutation(`
{ "data": { "updateIssueIssueType": { "issue": { "id": "123" } } } }`,
func(inputs map[string]interface{}) {
assert.Equal(t, "123", inputs["issueId"])
assert.Nil(t, inputs["issueTypeId"])
}),
)
},
stdout: "https://github.com/OWNER/REPO/issue/123\n",
},
{
name: "interactive edit type prompt",
input: &EditOptions{