Skip to content

PR merge command with delete branch closes the PR #7011

@setu4993

Description

@setu4993

Describe the bug

On repos with merge queues enabled, using gh pr merge with --delete-branch forces the PR to be closed before merging it.

A clear and concise description of what the bug is.

gh --version: 2.23.0

Steps to reproduce the behavior

  1. Create a repo in a team / enterprise org.
  2. Enable merge queues.
  3. Create a PR.
  4. On the branch for the PR, using gh, run: gh pr merge --squash --delete-branch
  5. Output in terminal:
! The merge strategy for main is set by the merge queue
✓ Pull request #1 will be added to the merge queue for main when ready
From https://github.com/org/repo
 * branch              main       -> FETCH_HEAD
Already up to date.
✓ Deleted branch fix/merge-queue-issue and switched to branch main
  1. On the repo, PR gets added to the merge queue.
  2. But, the remote branch is deleted immediately after (before merge), which closes the PR and removes it from the merge queue.

Expected vs actual behavior

After 5:
6. On the repo, PR gets added to the merge queue.
7. Remote branch is persisted until merge.
8. Merge queue is executed nominally.
9. If merge is successful, delete remote branch, mark PR as merged. If merge fails, keep remote branch and keep PR open.

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedbugSomething isn't workinggh-prrelating to the gh pr commandp3Affects a small number of users or is largely cosmeticplatformProblems with the GitHub platform rather than the CLI client

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions