Unlink a child Issue's Sub-issue link from the parent Issue.
Prerequisites
ghThe CLI is installed and authenticated- You have access rights to the target repository
Input
Collect the following information from the user:
- Parent Issue:
owner/repo#numberformat or GitHub URL - Child Issue:
owner/repo#numberformat or GitHub URL
Steps
Step 1: Get the Issue's Node ID
# 親 Issue
PARENT_ID=$(gh api graphql -f query='
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
issue(number: $number) { id }
}
}' -f owner="OWNER" -f repo="REPO" -F number=NUMBER \
-q '.data.repository.issue.id')
# 子 Issue
CHILD_ID=$(gh api graphql -f query='
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
issue(number: $number) { id }
}
}' -f owner="OWNER" -f repo="REPO" -F number=NUMBER \
-q '.data.repository.issue.id')
Step 2: Unlink with the removeSubIssue mutation
gh api graphql -f query='
mutation($parent: ID!, $child: ID!) {
removeSubIssue(input: {issueId: $parent, subIssueId: $child}) {
issue { id title }
subIssue { id title }
}
}' -f parent="$PARENT_ID" -f child="$CHILD_ID"
Step 3: Check the result
If the unlinking succeeds, display the titles of the parent Issue and child Issue and report the result.
Notes
- If the link does not exist, an error is returned
- Unlinking does not delete the Issue itself (only the link relationship is removed)