Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

The --push flag in init and upgrade commands now validates the current branch and requires user confirmation before committing/pushing changes.

Changes

  • Remote repository requirement: The --push flag now requires a remote repository to be configured. Operations fail immediately with a clear error if no remote exists.

  • Default branch validation: Queries GitHub API to verify current branch matches repository default before pushing.

  • User confirmation: Prompts for explicit confirmation before mutating git operations. Auto-confirms in CI environments (detected via CI, CONTINUOUS_INTEGRATION, GITHUB_ACTIONS env vars).

  • New helper functions (pkg/cli/git.go):

    • getDefaultBranch() - Fetches default branch via gh api
    • checkOnDefaultBranch(verbose bool) - Validates branch match and remote existence
    • confirmPushOperation(verbose bool) - Interactive confirmation prompt

Behavior

Before push, the flow now validates:

# 1. Requires remote repository
$ gh aw init --push
ℹ Checking current branch...
✗ cannot push: --push requires a remote repository to be configured

# 2. Check current branch matches default
$ gh aw init --push
ℹ Checking current branch...
✗ cannot push: not on default branch: current branch is 'feature', default branch is 'main'

# 3. Prompt for confirmation (outside CI)
$ gh aw init --push
ℹ Checking current branch...
✓ On default branch: main

⚠ This will commit and push changes to the remote repository.
? Do you want to proceed with commit and push? [Yes/No]

In CI environments, confirmation is automatic with no prompt shown.

Original prompt

The "--push" feature in init/upgrade should:

  • check git is on the repo default branch
  • confirm with user in non-CI environment before issuing any mutating git operation

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

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
Copy link
Contributor

@copilot if there is NO remote cancel.

Copilot AI changed the title [WIP] Add validation for push feature in init/upgrade Add default branch check and user confirmation to --push flag Jan 22, 2026
Copilot AI requested a review from pelikhan January 22, 2026 16:23
@pelikhan pelikhan marked this pull request as ready for review January 22, 2026 16:27
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot if there is NO remote cancel.

Done. The --push flag now fails immediately if no remote is configured with error: --push requires a remote repository to be configured

Fixed in commit 921d75f.

Example:

$ gh aw init --push
ℹ Checking current branch...
✗ cannot push: --push requires a remote repository to be configured

@pelikhan pelikhan merged commit d818aa5 into main Jan 22, 2026
@pelikhan pelikhan deleted the copilot/add-push-feature-validation branch January 22, 2026 16:34
github-actions bot pushed a commit that referenced this pull request Jan 22, 2026
Updates CLI documentation to reflect the safety features added to the
--push flag in PR #11343:

- Remote repository requirement
- Default branch validation
- User confirmation prompt (auto-confirmed in CI)

Updated documentation for:
- gh aw init --push
- gh aw run --push
- gh aw upgrade --push

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
pelikhan pushed a commit that referenced this pull request Jan 22, 2026
Updates CLI documentation to reflect the safety features added to the
--push flag in PR #11343:

- Remote repository requirement
- Default branch validation
- User confirmation prompt (auto-confirmed in CI)

Updated documentation for:
- gh aw init --push
- gh aw run --push
- gh aw upgrade --push

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
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