-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Describe the bug
When using gh pr merge --delete-branch, the command sometimes fails, if the branch was deleted already. This is unintuitive, since I want to make sure the branch is cleaned up and don't care how it happens, unless it interferes with the actual command.
#1279 already addresses this behavior, but I'm still getting an error.
I wondered, whether this is intentional or not. If intentional, where is the difference to the behavior addressed in the aforementioned PR and how I should go about ensuring the branch is gone after the merge, without risking a pipeline fail.
Affected version
GitHub CLI 2.74.2 (pipeline ran today and was using the Ubuntu 24.04 runner image, thus this is the installed version)
Steps to reproduce the behavior
- Write pipeline which merges a PR
- Set the repository to delete the branch itself (or insert a sleep into the pipeline and do it yourself)
- Let the pipeline run the "gh pr merge --delete-branch" command on that PR
ghwill error with aHTTP 404
Expected vs actual behavior
I'd expect the command to not error, but gracefully handle the error and suppressing it, since it matches the intent.
Currently it fails with failed to delete remote branch <redacted>: HTTP 404: Reference does not exist (https://api.github.com/repos/<redacted>).
#1279 already addresses this issue, but the caught error doesn't include the HTTP 404 I'm observing here.
I'd argue, that the command should not raise this error, since my intention is "branch should be cleaned up and gone after merge". If the branch is already gone, that's fine, as far as I'm concerned. The fact, that the branch was deleted by some other actor has no impact on my gh pr merge command, since the merge already happened, thus the command shouldn't care and shouldn't fail, just because it could not delete the branch by itself.
Logs
There is only one relevant log line, as gh pr merge doesn't output anything else for me.
failed to delete remote branch <redacted>: HTTP 404: Reference does not exist (https://api.github.com/repos/<redacted>)