-
Notifications
You must be signed in to change notification settings - Fork 720
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
Conversation
There was a problem hiding this 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"}, |
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <[email protected]>
* 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]>
* 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]>
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.