(ctx context.Context, client *github.Client, owner string, repo string, issueNumber int, subIssueID int, replaceParent bool)
| 1414 | } |
| 1415 | |
| 1416 | func AddSubIssue(ctx context.Context, client *github.Client, owner string, repo string, issueNumber int, subIssueID int, replaceParent bool) (*mcp.CallToolResult, error) { |
| 1417 | subIssueRequest := github.SubIssueRequest{ |
| 1418 | SubIssueID: int64(subIssueID), |
| 1419 | ReplaceParent: github.Ptr(replaceParent), |
| 1420 | } |
| 1421 | |
| 1422 | subIssue, resp, err := client.SubIssue.Add(ctx, owner, repo, int64(issueNumber), subIssueRequest) |
| 1423 | if err != nil { |
| 1424 | return ghErrors.NewGitHubAPIErrorResponse(ctx, |
| 1425 | "failed to add sub-issue", |
| 1426 | resp, |
| 1427 | err, |
| 1428 | ), nil |
| 1429 | } |
| 1430 | |
| 1431 | defer func() { _ = resp.Body.Close() }() |
| 1432 | |
| 1433 | if resp.StatusCode != http.StatusCreated { |
| 1434 | body, err := io.ReadAll(resp.Body) |
| 1435 | if err != nil { |
| 1436 | return nil, fmt.Errorf("failed to read response body: %w", err) |
| 1437 | } |
| 1438 | return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to add sub-issue", resp, body), nil |
| 1439 | } |
| 1440 | |
| 1441 | r, err := json.Marshal(subIssue) |
| 1442 | if err != nil { |
| 1443 | return nil, fmt.Errorf("failed to marshal response: %w", err) |
| 1444 | } |
| 1445 | |
| 1446 | return utils.NewToolResultText(string(r)), nil |
| 1447 | } |
| 1448 | |
| 1449 | func RemoveSubIssue(ctx context.Context, client *github.Client, owner string, repo string, issueNumber int, subIssueID int) (*mcp.CallToolResult, error) { |
| 1450 | subIssueRequest := github.SubIssueRequest{ |
no test coverage detected