Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4a485f

Browse files
committed
use new getClient function inadd and reply pr review tools
1 parent90a5d0d commite4a485f

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

‎pkg/github/pullrequests.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ func GetPullRequestComments(getClient GetClientFn, t translations.TranslationHel
645645
}
646646

647647
// AddPullRequestReviewComment creates a tool to add a review comment to a pull request.
648-
funcAddPullRequestReviewComment(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
648+
funcAddPullRequestReviewComment(getClientGetClientFn,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
649649
returnmcp.NewTool("add_pull_request_review_comment",
650650
mcp.WithDescription(t("TOOL_ADD_PULL_REQUEST_COMMENT_DESCRIPTION","Add a review comment to a pull request")),
651651
mcp.WithString("owner",
@@ -770,6 +770,11 @@ func AddPullRequestReviewComment(client *github.Client, t translations.Translati
770770
}
771771
}
772772

773+
client,err:=getClient(ctx)
774+
iferr!=nil {
775+
returnnil,fmt.Errorf("failed to get GitHub client: %w",err)
776+
}
777+
773778
createdComment,resp,err:=client.PullRequests.CreateComment(ctx,owner,repo,pullNumber,comment)
774779
iferr!=nil {
775780
returnnil,fmt.Errorf("failed to create pull request comment: %w",err)
@@ -794,7 +799,7 @@ func AddPullRequestReviewComment(client *github.Client, t translations.Translati
794799
}
795800

796801
// ReplyToPullRequestReviewComment creates a tool to reply to an existing review comment on a pull request.
797-
funcReplyToPullRequestReviewComment(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,
802+
funcReplyToPullRequestReviewComment(getClientGetClientFn,t translations.TranslationHelperFunc) (tool mcp.Tool,
798803
handler server.ToolHandlerFunc) {
799804
returnmcp.NewTool("reply_to_pull_request_review_comment",
800805
mcp.WithDescription(t("TOOL_REPLY_TO_PULL_REQUEST_REVIEW_COMMENT_DESCRIPTION","Reply to an existing review comment on a pull request")),
@@ -841,6 +846,11 @@ func ReplyToPullRequestReviewComment(client *github.Client, t translations.Trans
841846
returnmcp.NewToolResultError(err.Error()),nil
842847
}
843848

849+
client,err:=getClient(ctx)
850+
iferr!=nil {
851+
returnnil,fmt.Errorf("failed to get GitHub client: %w",err)
852+
}
853+
844854
createdReply,resp,err:=client.PullRequests.CreateCommentInReplyTo(ctx,owner,repo,pullNumber,body,int64(commentID))
845855
iferr!=nil {
846856
returnnil,fmt.Errorf("failed to reply to pull request comment: %w",err)

‎pkg/github/pullrequests_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ func Test_CreatePullRequest(t *testing.T) {
17221722

17231723
funcTest_AddPullRequestReviewComment(t*testing.T) {
17241724
mockClient:=github.NewClient(nil)
1725-
tool,_:=AddPullRequestReviewComment(mockClient,translations.NullTranslationHelper)
1725+
tool,_:=AddPullRequestReviewComment(stubGetClientFn(mockClient),translations.NullTranslationHelper)
17261726

17271727
assert.Equal(t,"add_pull_request_review_comment",tool.Name)
17281728
assert.NotEmpty(t,tool.Description)
@@ -1808,7 +1808,7 @@ func Test_AddPullRequestReviewComment(t *testing.T) {
18081808
t.Run(tc.name,func(t*testing.T) {
18091809
mockClient:=github.NewClient(tc.mockedClient)
18101810

1811-
_,handler:=AddPullRequestReviewComment(mockClient,translations.NullTranslationHelper)
1811+
_,handler:=AddPullRequestReviewComment(stubGetClientFn(mockClient),translations.NullTranslationHelper)
18121812

18131813
request:=createMCPRequest(tc.requestArgs)
18141814

@@ -1840,7 +1840,7 @@ func Test_AddPullRequestReviewComment(t *testing.T) {
18401840
funcTest_ReplyToPullRequestReviewComment(t*testing.T) {
18411841
// Verify tool definition once
18421842
mockClient:=github.NewClient(nil)
1843-
tool,_:=ReplyToPullRequestReviewComment(mockClient,translations.NullTranslationHelper)
1843+
tool,_:=ReplyToPullRequestReviewComment(stubGetClientFn(mockClient),translations.NullTranslationHelper)
18441844

18451845
assert.Equal(t,"reply_to_pull_request_review_comment",tool.Name)
18461846
assert.NotEmpty(t,tool.Description)
@@ -1918,7 +1918,7 @@ func Test_ReplyToPullRequestReviewComment(t *testing.T) {
19181918
t.Run(tc.name,func(t*testing.T) {
19191919
mockClient:=github.NewClient(tc.mockedClient)
19201920

1921-
_,handler:=ReplyToPullRequestReviewComment(mockClient,translations.NullTranslationHelper)
1921+
_,handler:=ReplyToPullRequestReviewComment(stubGetClientFn(mockClient),translations.NullTranslationHelper)
19221922

19231923
request:=createMCPRequest(tc.requestArgs)
19241924

‎pkg/github/server.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ func NewServer(getClient GetClientFn, version string, readOnly bool, t translati
5151
s.AddTool(GetPullRequestComments(getClient,t))
5252
s.AddTool(GetPullRequestReviews(getClient,t))
5353
if!readOnly {
54-
s.AddTool(MergePullRequest(client,t))
55-
s.AddTool(UpdatePullRequestBranch(client,t))
56-
s.AddTool(CreatePullRequestReview(client,t))
57-
s.AddTool(CreatePullRequest(client,t))
54+
s.AddTool(MergePullRequest(getClient,t))
55+
s.AddTool(UpdatePullRequestBranch(getClient,t))
56+
s.AddTool(CreatePullRequestReview(getClient,t))
57+
s.AddTool(CreatePullRequest(getClient,t))
5858
s.AddTool(UpdatePullRequest(getClient,t))
59-
s.AddTool(AddPullRequestReviewComment(client,t))
60-
s.AddTool(ReplyToPullRequestReviewComment(client,t))
59+
s.AddTool(AddPullRequestReviewComment(getClient,t))
60+
s.AddTool(ReplyToPullRequestReviewComment(getClient,t))
6161
}
6262

6363
// Add GitHub tools - Repositories

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp