cli/cli

`gh pr merge --auto -d` does not delete the branch after merge

arcivanov opened this issue · 3 comments

Describe the bug

A successful gh pr merge --auto -d does not delete the branch after a successful merge. It's unclear whether it's GH CLI problem or GH API.

Steps to reproduce the behavior

The PR in question that didn't have a branch auto-deleted is here: karellen/karellen-llvm#40
The branch was marked for auto-merge and auto-delete here: https://github.com/karellen/karellen-llvm/actions/runs/9048046223/job/24860694266#step:4:62 (line 61)

If this is not something that can be fixed in GH CLI and GH API the documentation update is necessary to note that it's not an expected behavior.

Expected vs actual behavior

Expected: PR auto-merge will be followed by auto-delete if delete is requested.
Actual: The PR is automatically merged but the branch remains.

Logs

Above in the action items.

Reading the code this is intentional behaviour when you provide --auto because as far as I know there is no way to tell the API to remember to delete the branch when the PR is automatically merged.

if !m.deleteBranch || m.crossRepoPR || m.autoMerge {
return nil
}

However, it's not clear to me why we allow both of these flags to be provided at the same time if this is the behaviour, instead of erroring and saying "you can't do that". This seems to have been the behaviour since the --auto flag was introduced. I agree with you that it is confusing.