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

get_file_content Match Paths in Git Tree if Full Path Unknown#650

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
LuluBeatson merged 11 commits intomainfromlulu/get-file
Jul 11, 2025

Conversation

LuluBeatson
Copy link
Contributor

@LuluBeatsonLuluBeatson commentedJul 7, 2025
edited
Loading

Adds additional steps to the end ofget_file_content so 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

  • Added additional processing to the end ofget_file_content so that if previous attempts to get the file/dir fail, then:
    • Get the recursive Git Tree containing tree and blob paths
    • Filters the tree for entries matching the inputpath arg. New funcfilterTree.
    • If any matches, returns a tool result containing the resolved ref & sha and matching paths. Else resume and return tool error result as normal.
  • Refactored logic for resolving inputref andsha into a functionresolveGitReference. This still handles refs of the formrefs/tags/{tag},refs/heads/{branch},refs/pull/{pr_number}/head and finds theircommit SHA.
  • Unit tests for new functionsfilterTree,resolveGitReference.
  • Update unit tests forGetFileContent to include mocking github client for resolving the git refs.

Examples

File (Unknown Path) from Branch with 2 Matches
get file "server.go" from github/github-mcp-server
image
File (Unknown Path) from Last Release
get file "server.go" from github/github-mcp-server from the last release
image
File from Pull Request
get repositories.go from PR #605 in github/github-mcp-server
image
File from Branch
get repositories.go from the lulu/get-file branch of github/github-mcp-server
image

TODO

  • Ensureref is not empty when we callclient.Git.GetTree
  • Ensure/ are handled properly byfilterPaths. Have unit tests.
  • Properly formatted errors

@LuluBeatsonLuluBeatson marked this pull request as ready for reviewJuly 8, 2025 12:21
@CopilotCopilotAI review requested due to automatic review settingsJuly 8, 2025 12:21
@LuluBeatsonLuluBeatson requested a review froma team as acode ownerJuly 8, 2025 12:21
Copy link
Contributor

@CopilotCopilotAI 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 enhances theget_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.

FileDescription
pkg/github/repositories.goRefactored Git reference resolution, added fuzzy path matching via Git tree, and improved error handling inGetFileContents
pkg/github/repositories_test.goAdded comprehensive unit tests for new functions and updated existing tests to include Git reference mocking

Copy link
Member

@omgitsadsomgitsads left a comment

Choose a reason for hiding this comment

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

This looks great! We just need to think about how to surface the API errors from theresolveGitReference func before this can:shipit:

LuluBeatson reacted with heart emoji
@LuluBeatson
Copy link
ContributorAuthor

LuluBeatson commentedJul 11, 2025
edited
Loading

Thank you@omgitsads! I've added the API errors to context

Screenshot: SuccessScreenshot 2025-07-11 at 16 02 37
Screenshot: Non-existent RefScreenshot 2025-07-11 at 16 02 20

Copy link
Member

@omgitsadsomgitsads left a comment

Choose a reason for hiding this comment

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

:shipit:

LuluBeatson reacted with laugh emoji
@LuluBeatsonLuluBeatson merged commitc23b1f9 intomainJul 11, 2025
16 checks passed
@LuluBeatsonLuluBeatson deleted the lulu/get-file branchJuly 11, 2025 15:23
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@omgitsadsomgitsadsomgitsads approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@LuluBeatson@omgitsads

[8]ページ先頭

©2009-2025 Movatter.jp