-
Notifications
You must be signed in to change notification settings - Fork 3.2k
refactor(pullrequests): convert PR tools to NewTool pattern #1595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: SamMorrowDrums/server-tool-refactor-issues
Are you sure you want to change the base?
refactor(pullrequests): convert PR tools to NewTool pattern #1595
Conversation
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>
There was a problem hiding this 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
ToolDependenciesstruct 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>
09e7bbd to
aa63e07
Compare
53ea837 to
1168315
Compare
t3xash0rnyt0ad777-commits
left a comment
There was a problem hiding this 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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
t3xash0rnyt0ad777-commits
left a comment
There was a problem hiding this 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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
Pull Request
Summary
Part of the stacked PR series for tool refactoring. This PR converts all 10 pull request tool functions in
pullrequests.goto use theNewToolpattern withToolDependenciesinjection.Converted Functions
PullRequestRead- Read PR details, diff, files, status, comments, reviewsCreatePullRequest- Create new pull requestsUpdatePullRequest- Update existing PRs (title, body, state, draft, reviewers)ListPullRequests- List PRs in a repositoryMergePullRequest- Merge pull requestsSearchPullRequests- Search for PRsUpdatePullRequestBranch- Update PR branch with base branch changesPullRequestReviewWrite- Create, submit, and delete PR reviewsAddCommentToPendingReview- Add comments to pending reviewsRequestCopilotReview- Request Copilot code reviewChanges
pullrequests.go: All 10 functions now:
t translations.TranslationHelperFuncparametertoolsets.ServerToolToolDependenciesfor runtime dependencies (GetClient, GetGQLClient, RepoAccessCache, Flags)tools.go: Updated to use direct function calls for PR functions (removed
NewServerToolLegacywrappers)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
script/lintpassesscript/testpasses