(ctx context.Context, deps ToolDependencies, args map[string]any, owner string)
| 326 | } |
| 327 | |
| 328 | func uiGetBranches(ctx context.Context, deps ToolDependencies, args map[string]any, owner string) (*mcp.CallToolResult, any, error) { |
| 329 | repo, err := RequiredParam[string](args, "repo") |
| 330 | if err != nil { |
| 331 | return utils.NewToolResultError(err.Error()), nil, nil |
| 332 | } |
| 333 | |
| 334 | client, err := deps.GetClient(ctx) |
| 335 | if err != nil { |
| 336 | return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil |
| 337 | } |
| 338 | |
| 339 | opts := &github.BranchListOptions{ |
| 340 | ListOptions: github.ListOptions{PerPage: 100}, |
| 341 | } |
| 342 | |
| 343 | var allBranches []*github.Branch |
| 344 | hasMore := false |
| 345 | for page := 1; ; page++ { |
| 346 | branches, resp, err := client.Repositories.ListBranches(ctx, owner, repo, opts) |
| 347 | if err != nil { |
| 348 | return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to list branches", resp, err), nil, nil |
| 349 | } |
| 350 | allBranches = append(allBranches, branches...) |
| 351 | if resp != nil && resp.Body != nil { |
| 352 | _ = resp.Body.Close() |
| 353 | } |
| 354 | if resp.NextPage == 0 { |
| 355 | break |
| 356 | } |
| 357 | if page >= uiGetMaxPages { |
| 358 | hasMore = true |
| 359 | break |
| 360 | } |
| 361 | opts.Page = resp.NextPage |
| 362 | } |
| 363 | |
| 364 | minimalBranches := make([]MinimalBranch, 0, len(allBranches)) |
| 365 | for _, branch := range allBranches { |
| 366 | minimalBranches = append(minimalBranches, convertToMinimalBranch(branch)) |
| 367 | } |
| 368 | |
| 369 | r, err := json.Marshal(map[string]any{ |
| 370 | "branches": minimalBranches, |
| 371 | "totalCount": len(minimalBranches), |
| 372 | "has_more": hasMore, |
| 373 | }) |
| 374 | if err != nil { |
| 375 | return utils.NewToolResultErrorFromErr("failed to marshal response", err), nil, nil |
| 376 | } |
| 377 | |
| 378 | return utils.NewToolResultText(string(r)), nil, nil |
| 379 | } |
| 380 | |
| 381 | func uiGetIssueFields(ctx context.Context, deps ToolDependencies, args map[string]any, owner string) (*mcp.CallToolResult, any, error) { |
| 382 | repo, err := RequiredParam[string](args, "repo") |
no test coverage detected