Skip to content

gh pr merge --delete-branch does not delete the remote branch when PR is merged via a merge queue - #10072

Closed
BagToad wants to merge 1 commit into
trunkfrom
kw/cli-7011-fix-delete-branch-with-merge-queue
Closed

gh pr merge --delete-branch does not delete the remote branch when PR is merged via a merge queue#10072
BagToad wants to merge 1 commit into
trunkfrom
kw/cli-7011-fix-delete-branch-with-merge-queue

Conversation

@BagToad

@BagToad BagToad commented Dec 12, 2024

Copy link
Copy Markdown
Member

Description

When running gh pr merge --delete-branch, no longer delete the remote branch if the PR is merged via a merge queue.

Attempting to delete the remote branch with a PR that will be merged with a merge queue can cause the PR to be unexpectedly closed and the remote branch deleted before a successful merge.

Resolves #7011

Demo

Current Behavior...

test-general on  main took 3s 
❯ gh pr checkout 18
branch 'BagToad-patch-5' set up to track 'origin/BagToad-patch-5'.
Switched to a new branch 'BagToad-patch-5'

test-general on  BagToad-patch-5 
❯ gh pr merge -d   
✓ Pull request bagtoad-enterprise-cloud-testing/test-general#18 will be added to the merge queue for main when ready
From https://github.com/bagtoad-enterprise-cloud-testing/test-general
 * branch            main       -> FETCH_HEAD
Already up to date.
✓ Deleted local branch BagToad-patch-5 and switched to branch main
✓ Deleted remote branch BagToad-patch-5

image

Proposed

test-general on  main took 2s 
❯ $ghbin pr checkout 18
branch 'BagToad-patch-5' set up to track 'origin/BagToad-patch-5'.
Switched to a new branch 'BagToad-patch-5'

test-general on  BagToad-patch-5 
❯ $ghbin pr merge -d                                           
✓ Pull request bagtoad-enterprise-cloud-testing/test-general#18 will be added to the merge queue for main when ready
From https://github.com/bagtoad-enterprise-cloud-testing/test-general
 * branch            main       -> FETCH_HEAD
Already up to date.
✓ Deleted local branch BagToad-patch-5 and switched to branch main
! Unable to delete remote branch BagToad-patch-5: pull request is in merge queue

image

Notes

To reproduce this, you have to configure a repository with a ruleset that requires a merge queue. The merge queue must be configured in some way that allows a PR to wait in the merge queue for some amount of time.

The following settings will work to accomplish that when one PR is in the merge queue:

merge queue settings image

image

When running `gh pr merge --delete-branch`, no longer delete the remote branch if the PR is merged via a merge queue.

Attempting to delete the remote branch with a PR that will be merged with a merge queue can cause the PR to be unexpectedly closed and the remote branch deleted before a successful merge.
@BagToad
BagToad marked this pull request as ready for review December 12, 2024 18:01
@BagToad
BagToad requested a review from a team as a code owner December 12, 2024 18:01
@BagToad
BagToad requested a review from jtmcg December 12, 2024 18:01
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Dec 12, 2024
@BagToad BagToad removed the external pull request originating outside of the CLI core team label Dec 12, 2024
@BagToad

BagToad commented Dec 12, 2024

Copy link
Copy Markdown
Member Author

Closing in favor of #10074

@BagToad BagToad closed this Dec 12, 2024
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.

PR merge command with delete branch closes the PR

2 participants