Skip to content

Use Raw repo resources #70

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

Merged
merged 5 commits into from
Apr 2, 2025

Conversation

SamMorrowDrums
Copy link
Collaborator

Small bodies are returned encoded by the API already, but unfortunately the MIME type info is not present, and by leveraging the raw resources, we are able to get the content type from the request headers, and also in theory return larger files than the file content limit.

@Copilot Copilot AI review requested due to automatic review settings April 2, 2025 21:21
Copy link
Contributor

@Copilot Copilot AI left a 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 updates the repository resource fetching logic to leverage raw endpoints, allowing retrieval of MIME type information via response headers and handling larger files. Key changes include:

  • Updating test logic in pkg/github/repository_resource_test.go to verify content fetching from raw URLs.
  • Refactoring the resource handler in pkg/github/repository_resource.go to determine MIME types based on file extension and HTTP response headers.
  • Introducing separate code paths for text and binary (blob) content based on the MIME type.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/github/repository_resource_test.go Updated tests to simulate raw endpoint responses and MIME type detection.
pkg/github/repository_resource.go Modified logic for fetching file content and determining MIME types.

Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more

),
requestArgs: map[string]any{
"owner": []string{"owner"},
"repo": []string{"repo"},
"path": []string{"README.md"},
"path": []string{"data.png"},
Copy link
Preview

Copilot AI Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the 'successful text content fetch' test, the request argument 'path' is set to 'data.png' while the mockTextContent has a name of 'README.md' (implying a .md extension). This discrepancy could lead to inconsistent MIME type resolution; please ensure that the file name and path are consistent.

Copilot uses AI. Check for mistakes.

@SamMorrowDrums SamMorrowDrums merged commit ede9f22 into repository_resource_tests Apr 2, 2025
12 checks passed
SamMorrowDrums added a commit that referenced this pull request Apr 2, 2025
* refactor to make testing easier

* not needed in handler func

* small cleanup

* create repository_resource_test

* remove chatty comments

* comment cleanup, function rename and some more tests

* fix test for ubuntu runner

* remove it for now

* make required args explicit instead of panic

* more tests and cleanup

* chore: use raw repo resources (#70)

* use raw repo URIs for resources

* fetch repository content from raw urls

* ensure no error in test write

* Update pkg/github/repository_resource.go

Co-authored-by: Copilot <[email protected]>

* use appropriate file name for text file test

---------

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Sam Morrow <[email protected]>
Co-authored-by: Copilot <[email protected]>
manian0430 pushed a commit to ChrisLally/github-mcp-server that referenced this pull request Apr 12, 2025
* refactor to make testing easier

* not needed in handler func

* small cleanup

* create repository_resource_test

* remove chatty comments

* comment cleanup, function rename and some more tests

* fix test for ubuntu runner

* remove it for now

* make required args explicit instead of panic

* more tests and cleanup

* chore: use raw repo resources (github#70)

* use raw repo URIs for resources

* fetch repository content from raw urls

* ensure no error in test write

* Update pkg/github/repository_resource.go

Co-authored-by: Copilot <[email protected]>

* use appropriate file name for text file test

---------

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Sam Morrow <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant