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_contents fetch refs improvements#1655

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

Open
almaleksia wants to merge5 commits intomain
base:main
Choose a base branch
Loading
fromalmaleksia/get_file_contents-fetch-refs-improvements

Conversation

@almaleksia
Copy link
Contributor

Summary

This PR improves ref resolution handling inget_file_contents tool.

  1. Sometimes LLM passes sha inref parameter which results in failure. This PR autocorrects it allowing shas to be passed as refs.
  2. Return custom errors when tool tried to resolvemain branch and failed - suggest to trymaster instead.

Why

We have lots of errors likefailed to resolve git reference: could not resolve ref "50e4e8b9178ca5c4e3c60d0022b3b041cc58c188" as a branch or a tag

Which means sha is passed as ref, this change aims to decrease amounts of such failures.

What changed

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

Prompts tested (tool changes only)

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Lint & tests

  • Linted locally with./script/lint
  • Tested locally with./script/test

Docs

  • Not needed
  • Updated (README / docs / examples)

@almaleksiaalmaleksia requested a review froma team as acode ownerDecember 19, 2025 13:59
CopilotAI review requested due to automatic review settingsDecember 19, 2025 13:59
Copy link
Contributor

CopilotAI 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_contents tool's ref resolution by auto-detecting Git commit SHAs passed in theref parameter and providing clearer error messages when the 'main' branch is not found.

  • AddslooksLikeSHA() function to detect full 40-character commit SHAs and bypass branch/tag resolution
  • Implements custom error messages suggesting 'master' when 'main' branch is not found
  • Adds comprehensive test coverage for the SHA detection logic

Reviewed changes

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

FileDescription
pkg/github/repositories.goAddslooksLikeSHA() helper function and integrates SHA detection intoresolveGitReference(); adds custom error messages for missing 'main' branch
pkg/github/repositories_test.goAdds unit tests forlooksLikeSHA() function and integration tests for SHA-based ref resolution inTest_resolveGitReference()

@almaleksiaalmaleksiaforce-pushed thealmaleksia/get_file_contents-fetch-refs-improvements branch from8988b78 tof76807bCompareDecember 19, 2025 14:04
@almaleksiaalmaleksia changed the titleAlmaleksia/get file contents fetch refs improvementsget_file_contents fetch refs improvementsDec 19, 2025
Copy link
Contributor

@mattdhollowaymattdholloway left a comment

Choose a reason for hiding this comment

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

looks great!looksLikeSHA is a really good idea

Copy link
Collaborator

@SamMorrowDrumsSamMorrowDrums left a comment

Choose a reason for hiding this comment

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

Very nice. Out of interest, do we have a way of looking up the default ref? And should we just try master or versa and just say what we did as part of the response? I guess it's just how things are that we need heuristics like this. But higher % success of achieving actual intent feels reasonable.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@mattdhollowaymattdhollowaymattdholloway approved these changes

@SamMorrowDrumsSamMorrowDrumsSamMorrowDrums approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@almaleksia@mattdholloway@SamMorrowDrums

[8]ページ先頭

©2009-2025 Movatter.jp