Skip to content

Gracefully handle when branches automatically deleted when PR is merged #1010

Description

@janko

Describe the feature or problem you’d like to solve

In our repo we have configured that branches are automatically deleted when a pull request is merged. The new gh pr merge command works great, but it produces a warning:

failed to delete remote branch <my-branch>: http error, 'https://api.github.com/repos/<my-organization>/<my-repo>/git/refs/heads/my-branch failed (422): 'Reference does not exist'

I assume it's because it tried to delete the remote branch, but couldn't find it because GitHub had already deleted it.

Proposed solution

It would be nice if the warning wasn't displayed in this case, so that it doesn't look like anything is wrong.

Additional context

Just in case, I've executed the following commands:

$ gh pr create
$ gh pr merge --squash

Activity

  1. mislav commented on May 27, 2020

    @mislav
    Contributor

    I assume it's because it tried to delete the remote branch, but couldn't find it because GitHub had already deleted it.

    Great catch; thank you for reporting!

    Ref. #982

  2. adamchainz commented on Jun 20, 2020

    @adamchainz

    It's not just a warning, the CLI exits with an error status code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions