Overwrite existing parent on --add-sub-issue

A sub-issue can have only one parent, so when --add-sub-issue is given
a candidate that already belongs to another parent the addSubIssue
mutation 422s with "Sub issue may only have one parent". Pass
replaceParent: true on this path so the take-over is silent.
This commit is contained in:
Kynan Ware 2026-05-12 21:35:50 -06:00
parent 6106bd3076
commit dbe8e34121
2 changed files with 3 additions and 3 deletions

View file

@ -665,7 +665,7 @@ func DeferredUpdateIssue(client *Client, opts DeferredUpdateIssueOptions) error
for _, id := range opts.AddSubIssueIDs {
mutations = append(mutations, func() error {
return AddSubIssue(client, opts.Hostname, opts.IssueID, id, false)
return AddSubIssue(client, opts.Hostname, opts.IssueID, id, true)
})
}
for _, id := range opts.RemoveSubIssueIDs {

View file

@ -1039,7 +1039,7 @@ func Test_editRun(t *testing.T) {
httpmock.GraphQLMutation(`{ "data": { "addSubIssue": { "issue": { "id": "100" } } } }`,
func(inputs map[string]interface{}) {
assert.Equal(t, "100", inputs["issueId"])
assert.Equal(t, false, inputs["replaceParent"])
assert.Equal(t, true, inputs["replaceParent"])
}),
)
reg.Register(
@ -1049,7 +1049,7 @@ func Test_editRun(t *testing.T) {
httpmock.GraphQLMutation(`{ "data": { "addSubIssue": { "issue": { "id": "100" } } } }`,
func(inputs map[string]interface{}) {
assert.Equal(t, "100", inputs["issueId"])
assert.Equal(t, false, inputs["replaceParent"])
assert.Equal(t, true, inputs["replaceParent"])
}),
)
},