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

Commit9680b24

Browse files
committed
comment cleanup, function rename and some more tests
1 parent2fdda7c commit9680b24

File tree

3 files changed

+49
-24
lines changed

3 files changed

+49
-24
lines changed

‎pkg/github/repository_resource.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,53 @@ import (
1313
"github.com/mark3labs/mcp-go/server"
1414
)
1515

16-
//getRepositoryContent defines the resource template and handler forthe Repository Content API.
17-
funcgetRepositoryContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
16+
//getRepositoryResourceContent defines the resource template and handler forgetting repository content.
17+
funcgetRepositoryResourceContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
1818
returnmcp.NewResourceTemplate(
1919
"repo://{owner}/{repo}/contents{/path*}",// Resource template
2020
t("RESOURCE_REPOSITORY_CONTENT_DESCRIPTION","Repository Content"),
2121
),
22-
repoContentsResourceHandler(client)
22+
repositoryResourceContentsHandler(client)
2323
}
2424

25-
// getRepositoryContent defines the resource template and handler forthe Repository Content API.
26-
funcgetRepositoryBranchContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
25+
// getRepositoryContent defines the resource template and handler forgetting repository content for a branch.
26+
funcgetRepositoryResourceBranchContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
2727
returnmcp.NewResourceTemplate(
2828
"repo://{owner}/{repo}/refs/heads/{branch}/contents{/path*}",// Resource template
2929
t("RESOURCE_REPOSITORY_CONTENT_BRANCH_DESCRIPTION","Repository Content for specific branch"),
3030
),
31-
repoContentsResourceHandler(client)
31+
repositoryResourceContentsHandler(client)
3232
}
3333

34-
//getRepositoryContent defines the resource template and handler forthe Repository Content API.
35-
funcgetRepositoryCommitContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
34+
//getRepositoryResourceCommitContent defines the resource template and handler forgetting repository content for a commit.
35+
funcgetRepositoryResourceCommitContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
3636
returnmcp.NewResourceTemplate(
3737
"repo://{owner}/{repo}/sha/{sha}/contents{/path*}",// Resource template
3838
t("RESOURCE_REPOSITORY_CONTENT_COMMIT_DESCRIPTION","Repository Content for specific commit"),
3939
),
40-
repoContentsResourceHandler(client)
40+
repositoryResourceContentsHandler(client)
4141
}
4242

43-
//getRepositoryContent defines the resource template and handler forthe Repository Content API.
44-
funcgetRepositoryTagContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
43+
//getRepositoryResourceTagContent defines the resource template and handler forgetting repository content for a tag.
44+
funcgetRepositoryResourceTagContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
4545
returnmcp.NewResourceTemplate(
4646
"repo://{owner}/{repo}/refs/tags/{tag}/contents{/path*}",// Resource template
4747
t("RESOURCE_REPOSITORY_CONTENT_TAG_DESCRIPTION","Repository Content for specific tag"),
4848
),
49-
repoContentsResourceHandler(client)
49+
repositoryResourceContentsHandler(client)
5050
}
5151

52-
//getRepositoryContent defines the resource template and handler forthe Repository Content API.
53-
funcgetRepositoryPrContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
52+
//getRepositoryResourcePrContent defines the resource template and handler forgetting repository content for a pull request.
53+
funcgetRepositoryResourcePrContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
5454
returnmcp.NewResourceTemplate(
5555
"repo://{owner}/{repo}/refs/pull/{pr_number}/head/contents{/path*}",// Resource template
5656
t("RESOURCE_REPOSITORY_CONTENT_PR_DESCRIPTION","Repository Content for specific pull request"),
5757
),
58-
repoContentsResourceHandler(client)
58+
repositoryResourceContentsHandler(client)
5959
}
6060

61-
funcrepoContentsResourceHandler(client*github.Client)func(ctx context.Context,request mcp.ReadResourceRequest) ([]mcp.ResourceContents,error) {
62-
returnfunc(ctx context.Context,request mcp.ReadResourceRequest) ([]mcp.ResourceContents,error) {// Extract parameters from request.Params.URI
61+
funcrepositoryResourceContentsHandler(client*github.Client)func(ctx context.Context,request mcp.ReadResourceRequest) ([]mcp.ResourceContents,error) {
62+
returnfunc(ctx context.Context,request mcp.ReadResourceRequest) ([]mcp.ResourceContents,error) {
6363

6464
owner:=request.Params.Arguments["owner"].([]string)[0]
6565
repo:=request.Params.Arguments["repo"].([]string)[0]

‎pkg/github/repository_resource_test.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import (
66
"net/http"
77
"testing"
88

9+
"github.com/github/github-mcp-server/pkg/translations"
910
"github.com/google/go-github/v69/github"
1011
"github.com/mark3labs/mcp-go/mcp"
1112
"github.com/migueleliasweb/go-github-mock/src/mock"
1213
"github.com/stretchr/testify/assert"
1314
"github.com/stretchr/testify/require"
1415
)
1516

16-
funcTest_RepoContentsResourceHandler(t*testing.T) {
17+
funcTest_repositoryResourceContentsHandler(t*testing.T) {
1718
mockDirContent:= []*github.RepositoryContent{
1819
{
1920
Type:github.Ptr("file"),
@@ -143,7 +144,7 @@ func Test_RepoContentsResourceHandler(t *testing.T) {
143144
for_,tc:=rangetests {
144145
t.Run(tc.name,func(t*testing.T) {
145146
client:=github.NewClient(tc.mockedClient)
146-
handler:=repoContentsResourceHandler(client)
147+
handler:=repositoryResourceContentsHandler(client)
147148

148149
request:= mcp.ReadResourceRequest{
149150
Params:struct {
@@ -167,3 +168,27 @@ func Test_RepoContentsResourceHandler(t *testing.T) {
167168
})
168169
}
169170
}
171+
172+
funcTest_getRepositoryResourceContent(t*testing.T) {
173+
tmpl,_:=getRepositoryResourceContent(nil,translations.NullTranslationHelper)
174+
require.Equal(t,"repo://{owner}/{repo}/contents{/path*}",tmpl.URITemplate.Raw())
175+
}
176+
177+
funcTest_getRepositoryResourceBranchContent(t*testing.T) {
178+
tmpl,_:=getRepositoryResourceBranchContent(nil,translations.NullTranslationHelper)
179+
require.Equal(t,"repo://{owner}/{repo}/refs/heads/{branch}/contents{/path*}",tmpl.URITemplate.Raw())
180+
}
181+
funcTest_getRepositoryResourceCommitContent(t*testing.T) {
182+
tmpl,_:=getRepositoryResourceCommitContent(nil,translations.NullTranslationHelper)
183+
require.Equal(t,"repo://{owner}/{repo}/sha/{sha}/contents{/path*}",tmpl.URITemplate.Raw())
184+
}
185+
186+
funcTest_getRepositoryResourceTagContent(t*testing.T) {
187+
tmpl,_:=getRepositoryResourceTagContent(nil,translations.NullTranslationHelper)
188+
require.Equal(t,"repo://{owner}/{repo}/refs/tags/{tag}/contents{/path*}",tmpl.URITemplate.Raw())
189+
}
190+
191+
funcTest_getRepositoryResourcePrContent(t*testing.T) {
192+
tmpl,_:=getRepositoryResourcePrContent(nil,translations.NullTranslationHelper)
193+
require.Equal(t,"repo://{owner}/{repo}/refs/pull/{pr_number}/head/contents{/path*}",tmpl.URITemplate.Raw())
194+
}

‎pkg/github/server.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func NewServer(client *github.Client, readOnly bool, t translations.TranslationH
2525
server.WithLogging())
2626

2727
// Add GitHub Resources
28-
s.AddResourceTemplate(getRepositoryContent(client,t))
29-
s.AddResourceTemplate(getRepositoryBranchContent(client,t))
30-
s.AddResourceTemplate(getRepositoryCommitContent(client,t))
31-
s.AddResourceTemplate(getRepositoryTagContent(client,t))
32-
s.AddResourceTemplate(getRepositoryPrContent(client,t))
28+
s.AddResourceTemplate(getRepositoryResourceContent(client,t))
29+
s.AddResourceTemplate(getRepositoryResourceBranchContent(client,t))
30+
s.AddResourceTemplate(getRepositoryResourceCommitContent(client,t))
31+
s.AddResourceTemplate(getRepositoryResourceTagContent(client,t))
32+
s.AddResourceTemplate(getRepositoryResourcePrContent(client,t))
3333

3434
// Add GitHub tools - Issues
3535
s.AddTool(getIssue(client,t))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp