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

Commit23b16cf

Browse files
anant-rustagiAnant rustagi
and
Anant rustagi
authored
feat: add pagination support to get_pull_request_files tool (#561)
- Add WithPagination() to tool definition- Use OptionalPaginationParams to handle page and perPage parameters- Pass pagination parameters to GitHub API ListFiles call- Update tests to include pagination scenarios- Update tool schema snapshotFixes#527Co-authored-by: Anant rustagi <anantrustagi@Anants-MacBook-Pro.local>
1 parent2a2df24 commit23b16cf

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

‎pkg/github/__toolsnaps__/get_pull_request_files.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
"description":"Repository owner",
1111
"type":"string"
1212
},
13+
"page": {
14+
"description":"Page number for pagination (min 1)",
15+
"minimum":1,
16+
"type":"number"
17+
},
18+
"perPage": {
19+
"description":"Results per page for pagination (min 1, max 100)",
20+
"maximum":100,
21+
"minimum":1,
22+
"type":"number"
23+
},
1324
"pullNumber": {
1425
"description":"Pull request number",
1526
"type":"number"

‎pkg/github/pullrequests.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ func GetPullRequestFiles(getClient GetClientFn, t translations.TranslationHelper
553553
mcp.Required(),
554554
mcp.Description("Pull request number"),
555555
),
556+
WithPagination(),
556557
),
557558
func(ctx context.Context,request mcp.CallToolRequest) (*mcp.CallToolResult,error) {
558559
owner,err:=RequiredParam[string](request,"owner")
@@ -567,12 +568,19 @@ func GetPullRequestFiles(getClient GetClientFn, t translations.TranslationHelper
567568
iferr!=nil {
568569
returnmcp.NewToolResultError(err.Error()),nil
569570
}
571+
pagination,err:=OptionalPaginationParams(request)
572+
iferr!=nil {
573+
returnmcp.NewToolResultError(err.Error()),nil
574+
}
570575

571576
client,err:=getClient(ctx)
572577
iferr!=nil {
573578
returnnil,fmt.Errorf("failed to get GitHub client: %w",err)
574579
}
575-
opts:=&github.ListOptions{}
580+
opts:=&github.ListOptions{
581+
PerPage:pagination.perPage,
582+
Page:pagination.page,
583+
}
576584
files,resp,err:=client.PullRequests.ListFiles(ctx,owner,repo,pullNumber,opts)
577585
iferr!=nil {
578586
returnghErrors.NewGitHubAPIErrorResponse(ctx,

‎pkg/github/pullrequests_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@ func Test_GetPullRequestFiles(t *testing.T) {
576576
assert.Contains(t,tool.InputSchema.Properties,"owner")
577577
assert.Contains(t,tool.InputSchema.Properties,"repo")
578578
assert.Contains(t,tool.InputSchema.Properties,"pullNumber")
579+
assert.Contains(t,tool.InputSchema.Properties,"page")
580+
assert.Contains(t,tool.InputSchema.Properties,"perPage")
579581
assert.ElementsMatch(t,tool.InputSchema.Required, []string{"owner","repo","pullNumber"})
580582

581583
// Setup mock PR files for success case
@@ -622,6 +624,24 @@ func Test_GetPullRequestFiles(t *testing.T) {
622624
expectError:false,
623625
expectedFiles:mockFiles,
624626
},
627+
{
628+
name:"successful files fetch with pagination",
629+
mockedClient:mock.NewMockedHTTPClient(
630+
mock.WithRequestMatch(
631+
mock.GetReposPullsFilesByOwnerByRepoByPullNumber,
632+
mockFiles,
633+
),
634+
),
635+
requestArgs:map[string]interface{}{
636+
"owner":"owner",
637+
"repo":"repo",
638+
"pullNumber":float64(42),
639+
"page":float64(2),
640+
"perPage":float64(10),
641+
},
642+
expectError:false,
643+
expectedFiles:mockFiles,
644+
},
625645
{
626646
name:"files fetch fails",
627647
mockedClient:mock.NewMockedHTTPClient(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp