fix: retry push_files on concurrent branch updates
Summary
- Add retry logic to
push_fileswhen GitHub rejects a ref update with a non-fast-forward conflict, which occurs during rapid sequential pushes to the same branch - Normalize the
filesargument from multiple MCP host encodings ([]any, typed slices, JSON strings) - Extract git push helpers with regression tests covering conflict retry and argument parsing
Problem
Issue #2481 reports intermittent commit/push failures during heavy multi-file refactoring sessions. The push_files tool performed a read-modify-write sequence (get ref → create tree → create commit → update ref) without handling concurrent branch updates. When another push landed between the initial ref read and UpdateRef, GitHub returned a 422 non-fast-forward error, leaving an orphaned commit and a failed push.
Some MCP hosts also send the files parameter in encodings that failed the strict []any type assertion, producing JSON parsing errors.
Test plan
- [x]
go test ./pkg/github/... - [x] New unit test verifies retry succeeds after initial 422 on
UpdateRef - [x] New unit tests verify flexible
filesparameter parsing
Closes #2481
Rebased onto latest main and force-pushed (27178da → 1983ac7). go test ./pkg/github/... -run Push passes locally on Go 1.25.
Merge-ready check-in
This PR looks ready for maintainer review/merge when you have a moment.
- Change: fix: retry push_files on concurrent branch updates
- CI: green / passing
- Review: REVIEW_REQUIRED (mergeable: MERGEABLE)
Happy to rebase or address any remaining feedback. Thanks for maintaining the project.