Skip to content

Conversation

@SamMorrowDrums
Copy link
Collaborator

Pull Request

Summary

Part of the stacked PR series for tool refactoring. This PR converts all 10 pull request tool functions in pullrequests.go to use the NewTool pattern with ToolDependencies injection.

Converted Functions

  • PullRequestRead - Read PR details, diff, files, status, comments, reviews
  • CreatePullRequest - Create new pull requests
  • UpdatePullRequest - Update existing PRs (title, body, state, draft, reviewers)
  • ListPullRequests - List PRs in a repository
  • MergePullRequest - Merge pull requests
  • SearchPullRequests - Search for PRs
  • UpdatePullRequestBranch - Update PR branch with base branch changes
  • PullRequestReviewWrite - Create, submit, and delete PR reviews
  • AddCommentToPendingReview - Add comments to pending reviews
  • RequestCopilotReview - Request Copilot code review

Changes

  1. pullrequests.go: All 10 functions now:

    • Take only t translations.TranslationHelperFunc parameter
    • Return toolsets.ServerTool
    • Use ToolDependencies for runtime dependencies (GetClient, GetGQLClient, RepoAccessCache, Flags)
  2. tools.go: Updated to use direct function calls for PR functions (removed NewServerToolLegacy wrappers)

  3. pullrequests_test.go: Updated all tests to use new handler pattern:

    • serverTool := FunctionName(translations.NullTranslationHelper)
    • deps := ToolDependencies{...}
    • handler := serverTool.Handler(deps)
    • result, err := handler(ctx, &request) (2 return values)

PR Stack

This is part of a stacked PR series:

Testing

  • All existing tests updated and passing
  • script/lint passes
  • script/test passes

Convert all 8 tool functions in issues.go to use the new NewTool
helper pattern which standardizes dependency injection:

- IssueRead: GetClient, GetGQLClient, RepoAccessCache, Flags
- ListIssueTypes: GetClient
- AddIssueComment: GetClient
- SubIssueWrite: GetClient
- SearchIssues: GetClient
- IssueWrite: GetClient, GetGQLClient
- ListIssues: GetGQLClient
- AssignCopilotToIssue: GetGQLClient

Updated tools.go to use direct function calls instead of
NewServerToolLegacy wrappers. Updated all tests in issues_test.go
to use the new ToolDependencies pattern and Handler() method.

Co-authored-by: Adam Holt <oholt@github.com>
Copilot AI review requested due to automatic review settings December 13, 2025 14:13
@SamMorrowDrums SamMorrowDrums requested a review from a team as a code owner December 13, 2025 14:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors 10 pull request tool functions in pullrequests.go to use the NewTool pattern with ToolDependencies injection, continuing the stacked PR series for tool standardization. The refactoring moves from passing dependencies as function parameters to injecting them at runtime through the ToolDependencies struct.

Key Changes:

  • All 10 PR tool functions now accept only a translation helper parameter and return toolsets.ServerTool
  • Runtime dependencies (GetClient, GetGQLClient, RepoAccessCache, Flags) are accessed via the ToolDependencies struct passed to handlers
  • Test patterns updated to use the new 2-return-value handler signature

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/github/tools.go Removed NewServerToolLegacy wrappers for all 10 PR functions, now calling them directly
pkg/github/pullrequests.go Refactored all 10 PR tool functions to use NewTool pattern with ToolDependencies injection instead of direct parameter passing
pkg/github/pullrequests_test.go Updated all test cases to use new handler pattern: create serverTool, build deps struct, get handler, and call with 2 return values

Review Result: The refactoring is clean, consistent, and follows the established pattern from previous PRs in the stack. All changes maintain existing functionality while improving the architecture. No issues found.

Convert all 10 pull request tool functions to use the NewTool
pattern with ToolDependencies injection:
- PullRequestRead
- CreatePullRequest
- UpdatePullRequest
- ListPullRequests
- MergePullRequest
- SearchPullRequests
- UpdatePullRequestBranch
- PullRequestReviewWrite
- AddCommentToPendingReview
- RequestCopilotReview

Update tools.go to use direct function calls (removing
NewServerToolLegacy wrappers) for PR functions.

Update all tests in pullrequests_test.go to use the new
handler pattern with deps and 2-value return.

Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com>
@SamMorrowDrums SamMorrowDrums force-pushed the SamMorrowDrums/server-tool-refactor-pullrequests branch from 09e7bbd to aa63e07 Compare December 13, 2025 14:16
@SamMorrowDrums SamMorrowDrums force-pushed the SamMorrowDrums/server-tool-refactor-issues branch from 53ea837 to 1168315 Compare December 13, 2025 14:17
Copy link

@t3xash0rnyt0ad777-commits t3xash0rnyt0ad777-commits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link

@t3xash0rnyt0ad777-commits t3xash0rnyt0ad777-commits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants