Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

The upgrade and init commands now support automatic commit/push workflow via --push flag. The implementation uses reusable git helper functions for consistency across commands.

Changes

Git Helper Functions (pkg/cli/git.go)

  • hasChangesToCommit() - Checks if there are any changes in the working directory
  • hasRemote() - Checks if a remote repository named 'origin' is configured
  • pullFromRemote() - Pulls latest changes from remote using rebase
  • stageAllChanges() - Stages all modified files using git add -A
  • pushToRemote() - Pushes current branch to remote repository
  • commitAndPushChanges() - Orchestrates the complete commit and push workflow

Commands Updated

  • upgrade command:

    • Pre-validation ensures clean working directory before starting upgrade
    • Post-upgrade automation uses git helpers for commit/push workflow
    • Commits with message "chore: upgrade agentic workflows"
    • Graceful degradation when no remote exists (test environments)
  • init command:

    • Added --push flag support
    • Pre-validation ensures clean working directory before initialization
    • Post-initialization automation uses same git helpers
    • Commits with message "chore: initialize agentic workflows"
    • Graceful degradation when no remote exists

Usage

# Upgrade command
gh aw upgrade --push            # Upgrade and auto-commit/push
gh aw upgrade --push --no-fix   # Update agent files only, then push

# Init command
gh aw init --push               # Initialize and auto-commit/push
gh aw init --no-mcp --push      # Skip MCP, then push

Implementation

Created reusable git helper functions in pkg/cli/git.go to avoid code duplication. Both upgrade and init commands use these helpers for consistent behavior. All git operations now use helper functions instead of direct exec.Command calls.

Original prompt

Add --push flag to the upgrade command to automatically commit/pull/push upon successful compilation

  • when enabled, ensures that git status is clean with no pending or staged changes before

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- 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>

// Check if there are any changes to commit
upgradeLog.Print("Checking for modified files")
cmd := exec.Command("git", "status", "--porcelain")
Copy link
Contributor

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

Copy link
Contributor Author

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 changes
  • hasRemote() - check for remote
  • pullFromRemote() - pull with rebase
  • stageAllChanges() - stage all changes
  • pushToRemote() - push to remote
  • commitAndPushChanges() - orchestrate full workflow

The upgrade command now uses these helpers instead of direct exec.Command calls.

Copilot AI changed the title [WIP] Add --push flag to upgrade command for automatic git operations Add --push flag to upgrade command for automatic commit/push Jan 22, 2026
@pelikhan
Copy link
Contributor

@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>
Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot refactor "--push" feature into helper in git package and add support to "init" command as well.

Use helpers to invoke git

Done in commit 32b7e5e:

  • Created reusable git helper functions in pkg/cli/git.go
  • Refactored upgrade command to use helpers
  • Added --push flag to init command with same helper functions
  • All git operations now use helpers instead of direct git commands

Usage:

gh aw init --push      # Initialize and auto-commit/push
gh aw upgrade --push   # Upgrade and auto-commit/push

Copilot AI changed the title Add --push flag to upgrade command for automatic commit/push Add --push flag to upgrade and init commands with reusable git helpers Jan 22, 2026
Copilot AI requested a review from pelikhan January 22, 2026 14:45
@pelikhan pelikhan marked this pull request as ready for review January 22, 2026 14:48
@pelikhan pelikhan merged commit 4357b7d into main Jan 22, 2026
83 checks passed
@pelikhan pelikhan deleted the copilot/add-push-flag-to-upgrade-command branch January 22, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants