Skip to content

feat(sync): add -y/--yes flag#136

Merged
boneskull merged 2 commits into
mainfrom
sync-yes
Jul 12, 2026
Merged

feat(sync): add -y/--yes flag#136
boneskull merged 2 commits into
mainfrom
sync-yes

Conversation

@boneskull

Copy link
Copy Markdown
Owner

This adds a -y/--yes flag to gh stack sync which accepts the default behavior when a branch has been merged into the trunk (which is to delete the branch).

This adds a `-y/--yes` flag to `gh stack sync` which accepts the default behavior when a branch has been merged into the trunk (which is to delete the branch).
Copilot AI review requested due to automatic review settings July 11, 2026 00:20
@boneskull

Copy link
Copy Markdown
Owner Author

📚 Pull Request Stack


Managed by gh-stack

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a -y/--yes flag to gh stack sync to automatically accept the default handling for branches detected as merged into trunk (deleting the merged branch) without prompting, aligning sync behavior with non-interactive defaults.

Changes:

  • Add -y/--yes flag wiring to gh stack sync, and thread it into merged-branch handling to skip the interactive prompt.
  • Document the new flag in the README sync command options table.
  • Add tests to ensure the flag appears in sync --help output, plus an internal helper test for merged-branch handling.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
README.md Documents the new -y/--yes flag for gh stack sync.
e2e/sync_test.go Adds an e2e help-output assertion that --yes is exposed.
cmd/sync.go Implements --yes flag and bypasses the merged-branch prompt when set.
cmd/sync_internal_test.go Adds internal test coverage around merged-branch handling with a yes parameter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/sync_internal_test.go Outdated
Comment thread cmd/sync_internal_test.go Outdated
Prior test could not distinguish between the `yes=true` path and the
existing non-interactive default: under `go test` (no TTY),
`prompt.IsInteractive()` is always false, so the delete path was taken
regardless of `yes`.

Fix by injecting `isInteractive func() bool` into `handleMergedBranch`
and passing `prompt.IsInteractive` at the call site in `runSync`.
Tests now force `isInteractive=true`, proving `yes=true` overrides the
interactive branch. A companion test covers the non-interactive default
(`yes=false` + forced non-interactive → delete).

Also replaced the ignored `git branch --list` error check with
`g.BranchExists` for a cleaner and reliable assertion.
Copilot AI review requested due to automatic review settings July 12, 2026 22:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@boneskull boneskull merged commit f7cf20c into main Jul 12, 2026
8 checks passed
@boneskull boneskull deleted the sync-yes branch July 12, 2026 22:42
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