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

Fix handling of multi path resources#1458

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletionpkg/github/repository_resource.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,7 +99,15 @@ func RepositoryResourceContentsHandler(getClient GetClientFn, getRawClient raw.G
return nil, errors.New("repo is required")
}

path := uriValues.Get("path").String()
pathValue := uriValues.Get("path")
pathComponents := pathValue.List()
var path string

if len(pathComponents) == 0 {
path = pathValue.String()
} else {
path = strings.Join(pathComponents, "/")
}

opts := &github.RepositoryContentGetOptions{}
rawOpts := &raw.ContentOpts{}
Expand Down
27 changes: 27 additions & 0 deletionspkg/github/repository_resource_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -123,6 +123,33 @@ func Test_repositoryResourceContents(t *testing.T) {
URI: "",
}}},
},
{
name: "successful text content fetch (HEAD)",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatchHandler(
raw.GetRawReposContentsByOwnerByRepoByPath,
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")

require.Contains(t, r.URL.Path, "pkg/github/actions.go")
_, err := w.Write([]byte("package actions\n\nfunc main() {\n // Sample Go file content\n}\n"))
require.NoError(t, err)
}),
),
),
uri: "repo://owner/repo/contents/pkg/github/actions.go",
handlerFn: func(getClient GetClientFn, getRawClient raw.GetRawClientFn, t translations.TranslationHelperFunc) mcp.ResourceHandler {
_, handler := GetRepositoryResourceContent(getClient, getRawClient, t)
return handler
},
expectedResponseType: resourceResponseTypeText,
expectedResult: &mcp.ReadResourceResult{
Contents: []*mcp.ResourceContents{{
Text: "package actions\n\nfunc main() {\n // Sample Go file content\n}\n",
MIMEType: "text/plain",
URI: "",
}}},
},
{
name: "successful text content fetch (branch)",
mockedClient: mock.NewMockedHTTPClient(
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp