get_file_content Match Paths in Git Tree if Full Path Unknown#650
Merged
LuluBeatson merged 11 commits intomainfrom Jul 11, 2025
Merged
get_file_content Match Paths in Git Tree if Full Path Unknown#650LuluBeatson merged 11 commits intomainfrom
get_file_content Match Paths in Git Tree if Full Path Unknown#650LuluBeatson merged 11 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the get_file_content function to handle cases where the provided path isn't found by checking the Git tree for possible matching paths that end with the provided path. The implementation includes comprehensive error handling and path resolution improvements.
- Refactored Git reference resolution logic into a dedicated function for better maintainability
- Added fuzzy path matching using Git tree traversal when exact paths fail
- Enhanced test coverage for the new functionality with proper mocking
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/github/repositories.go | Refactored Git reference resolution, added fuzzy path matching via Git tree, and improved error handling in GetFileContents |
| pkg/github/repositories_test.go | Added comprehensive unit tests for new functions and updated existing tests to include Git reference mocking |
LuluBeatson
commented
Jul 8, 2025
LuluBeatson
commented
Jul 8, 2025
omgitsads
requested changes
Jul 10, 2025
Member
omgitsads
left a comment
There was a problem hiding this comment.
This looks great! We just need to think about how to surface the API errors from the resolveGitReference func before this can ![]()
Contributor
Author
|
Thank you @omgitsads! I've added the API errors to context |
nickytonline
pushed a commit
to nickytonline/github-mcp-http
that referenced
this pull request
Oct 4, 2025
…ub#650) * add contingency to match path in git tree * resolveGitReference helper * fix: handling of directories * Test_filterPaths * filterPaths - trailing slashes * fix: close response body, improve error messages, docs * update tool result message about resolved git ref * unit test cases for filterPaths maxResults param * resolveGitReference - NewGitHubAPIErrorToCtx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Adds additional steps to the end of
get_file_contentso that if the provided path wasn't found, then we check the Git Tree for possible matching paths. A path matches if it ends with the provided path.Changes
get_file_contentso that if previous attempts to get the file/dir fail, then:patharg. New funcfilterTree.refandshainto a functionresolveGitReference. This still handles refs of the formrefs/tags/{tag},refs/heads/{branch},refs/pull/{pr_number}/headand finds their commit SHA.filterTree,resolveGitReference.GetFileContentto include mocking github client for resolving the git refs.Examples
File (Unknown Path) from Branch with 2 Matches
File (Unknown Path) from Last Release
File from Pull Request
File from Branch
TODO
refis not empty when we callclient.Git.GetTree/are handled properly byfilterPaths. Have unit tests.