-
Notifications
You must be signed in to change notification settings - Fork 36
Add --push flag to upgrade and init commands with reusable git helpers #11298
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
- Add Push field to UpgradeConfig struct - Add --push flag to upgrade command CLI - Check for clean working directory before upgrade when --push is enabled - Implement commit/pull/push logic after successful compilation - Handle cases where no remote is configured (test environments) - Add tests for --push flag functionality - Update help text with --push example Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
pkg/cli/upgrade_command.go
Outdated
|
|
||
| // Check if there are any changes to commit | ||
| upgradeLog.Print("Checking for modified files") | ||
| cmd := exec.Command("git", "status", "--porcelain") |
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.
@copilot move to helper in git package
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.
Done in commit 32b7e5e. Extracted git operations into reusable helper functions:
hasChangesToCommit()- check for changeshasRemote()- check for remotepullFromRemote()- pull with rebasestageAllChanges()- stage all changespushToRemote()- push to remotecommitAndPushChanges()- orchestrate full workflow
The upgrade command now uses these helpers instead of direct exec.Command calls.
|
@copilot refactor "--push" feature into helper in git package and add support to "init" command as well. Use helpers to invoke git |
- Extract git operations into reusable helper functions in git.go: - hasChangesToCommit() - check if there are changes to commit - hasRemote() - check if remote repository exists - pullFromRemote() - pull latest changes with rebase - stageAllChanges() - stage all changes with git add -A - pushToRemote() - push changes to remote - commitAndPushChanges() - orchestrate full commit/push workflow - Refactor upgrade_command.go to use new git helpers - Add --push flag to init command - Update all test files to include new push parameter - Update help text for both commands with --push examples Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in commit 32b7e5e:
Usage: gh aw init --push # Initialize and auto-commit/push
gh aw upgrade --push # Upgrade and auto-commit/push |
The
upgradeandinitcommands now support automatic commit/push workflow via--pushflag. The implementation uses reusable git helper functions for consistency across commands.Changes
Git Helper Functions (pkg/cli/git.go)
git add -ACommands Updated
upgrade command:
init command:
--pushflag supportUsage
Implementation
Created reusable git helper functions in
pkg/cli/git.goto avoid code duplication. Bothupgradeandinitcommands use these helpers for consistent behavior. All git operations now use helper functions instead of directexec.Commandcalls.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.