- Notifications
You must be signed in to change notification settings - Fork1.2k
feat: add include_sha parameter to get_file_contents tool#605
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
base:main
Are you sure you want to change the base?
Conversation
- Add include_sha boolean parameter to control metadata vs raw content retrieval- When include_sha=true, always use GitHub Contents API to ensure SHA is returned- When include_sha=false (default), maintain existing behavior with raw content preference- Unify GitHub API processing to handle both files and directories consistently- Improve error handling and fallback logic for better reliability- Update tool description and parameter documentation- Update toolsnap test file to reflect new parameterThis enhancement allows users to reliably obtain file metadata (SHA, size, type)regardless of file size, while maintaining backward compatibility with existing clients.
Add optional boolean parameter to retrieve file metadata instead of raw content.When include_sha=true, returns SHA, size, and other metadata via GitHub Contents API.Maintains backward compatibility and performance with Raw API as default.- Add include_sha parameter with comprehensive test coverage- Support metadata retrieval for both files and directories- Update tool description and schema validation
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 adds an optional include_sha parameter to the get_file_contents tool, allowing users to choose between fast raw content retrieval and detailed file metadata (including SHA) needed for file update operations.
- Introduce the include_sha boolean parameter to the tool schema and update its description.
- Modify the API call logic to conditionally use either the raw content or the GitHub Contents API based on the include_sha value.
- Update tests and snapshots to cover the new include_sha functionality.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
pkg/github/repositories_test.go | Added schema check for include_sha and new test cases for both metadata and raw content fetching. |
pkg/github/repositories.go | Extended tool description, added the include_sha parameter, and updated API call flow and error handling accordingly. |
pkg/github/toolsnaps/get_file_contents.snap | Updated snapshot description and schema to include the new include_sha parameter. |
Comments suppressed due to low confidence (1)
pkg/github/repositories.go:529
- [nitpick] Consider adding an inline comment explaining why the raw content API call is skipped when include_sha is true, to improve future maintainability and clarity.
if !includeSha && path != "" && !strings.HasSuffix(path, "/") {
Summary
This PR addresses issue#595 by adding an optional
include_sha
parameter to theget_file_contents
tool, providing a more flexible and performant solution than the previous approach in PR#599.Problem
The
get_file_contents
tool was missing the SHA hash in its response, which is essential for subsequent file update operations usingcreate_or_update_file
. The SHA is required by the GitHub API for any update operation.Solution
Instead of always returning metadata (as in PR#599), this PR adds an
include_sha
boolean parameter that allows users to explicitly choose between:Key Features
Usage Examples
Changes Made
include_sha
boolean parameter to tool schemaTesting
Supersedes
This PR supersedes#599 by providing a more user-friendly and performant solution to the same problem.
Closes#595
Supersedes#599