-
Notifications
You must be signed in to change notification settings - Fork 28
Refactor patch generation from workflow step to MCP server #4570
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
Conversation
- Move git patch generation from dedicated workflow step to MCP server - Generate patch when create_pull_request or push_to_pull_request_branch tools are called - Report error immediately when patch is empty (no changes) - Keep upload artifact step for backward compatibility with processing jobs - Update tests to reflect new behavior Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add comprehensive test suite for patch generation logic - Test empty patch detection and error handling - Test successful patch generation response structure - Test git command patterns and error messages - All tests pass successfully Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Run make fmt to format code - Run make agent-finish for full validation - All 87 workflows recompiled successfully - All tests pass, no lint errors Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
✅ Agentic Changeset Generator completed successfully. |
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 refactors git patch generation from a dedicated workflow step to the safe-outputs MCP server, where it executes when create_pull_request or push_to_pull_request_branch tools are called. This architectural change enables immediate error feedback when no changes exist, rather than discovering it later in processing jobs.
Key changes:
- Adds
generateGitPatch()function to the MCP server with two strategies (named branch and HEAD commits) - Handlers throw errors immediately if patch is empty or generation fails
- Removes the "Generate git patch" workflow step from main job
- Retains upload artifact step for backward compatibility with processing jobs
Reviewed changes
Copilot reviewed 85 out of 85 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/js/safe_outputs_mcp_server.cjs |
Added generateGitPatch() function with two fallback strategies and integration into create/push handlers |
pkg/workflow/js/safe_outputs_mcp_server_patch.test.cjs |
New test file with 217 lines covering patch generation logic, error handling, and git command patterns |
pkg/workflow/git_patch.go |
Renamed function from generateGitPatchStep() to generateGitPatchUploadStep() and removed patch generation logic |
pkg/workflow/compiler_yaml.go |
Updated function call and added explanatory comments about the architectural change |
pkg/workflow/git_patch_test.go |
Updated test expectations to verify patch generation step is NOT in main job |
pkg/workflow/patch_generation_test.go |
Updated test expectations and comments to reflect MCP server architecture |
.github/workflows/*.lock.yml |
Multiple compiled workflows now include the generateGitPatch() function and no longer have the "Generate git patch" step |
.changeset/patch-refactor-patch-generation-to-mcp-server.md |
Changeset documenting the refactoring |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Moves git patch generation from a dedicated workflow step to the safe-outputs MCP server, where it executes when
create_pull_requestorpush_to_pull_request_branchtools are called. This provides immediate error feedback when no changes exist, rather than discovering it later in processing jobs.Implementation
MCP Server (
safe_outputs_mcp_server.cjs)generateGitPatch()with two strategies: named branch and HEAD commitsWorkflow Compilation (
git_patch.go,compiler_yaml.go)generateGitPatchStep()→generateGitPatchUploadStep()Tests
safe_outputs_mcp_server_patch.test.cjswith 217 lines of coverageError Flow
Before:
After:
Error messages throw at tool invocation:
Backward Compatibility
Processing jobs continue downloading
aw.patchartifact as before. Upload step runsif: always()regardless of patch existence.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/user/usr/bin/gh gh api user --jq .login(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.