-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Improvements to push_files tool #1676
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
base: main
Are you sure you want to change the base?
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 enhances the push_files tool to automatically handle two common failure scenarios: empty repositories and non-existent branches. Instead of failing when encountering these conditions, the tool now initializes empty repositories with an initial commit and creates missing branches from the default branch.
Key changes:
- Added auto-initialization of empty repositories when a 409 Conflict status is detected
- Added auto-creation of branches from the default branch when a branch is not found
- Improved error handling and resource cleanup with nil checks before closing response bodies
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| pkg/github/repositories.go | Implements auto-init logic for empty repositories and auto-creation of non-existent branches; adds two helper functions initializeRepository and createReferenceFromDefaultBranch |
| pkg/github/repositories_test.go | Adds comprehensive test coverage for empty repository scenarios, branch auto-creation failures, and updates existing test expectations to match new behavior |
77142a8 to
bf28276
Compare
44a21fd to
7ea39cc
Compare
SamMorrowDrums
left a comment
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.
It's too big for me to review while off, but really nice improvement!
Summary
This PR aims to significantly reduce failure rate for push_files tool.
Why
push_files tool fails too often due to rigid assumptions that both ref that files are pushed to exists and repo is not empty. However, it is very often not the case and we shouldn't fail on such common cases.
MCP impact
Prompts tested (tool changes only)
Security / limits
Lint & tests
./script/lint./script/testDocs