Skip to content

Different exit code for gh pr create if pull request already exists #13571

@jessestricker

Description

@jessestricker

Describe the feature or problem you’d like to solve

I'm trying to replace the usage of the action create-pull-request with gh pr create in my GitHub workflows.
That action has the nice behavior that when the pull requests already exists, it does not fail but merely force-pushes an update to the head branch.

Now, I can easily replicate that like this:

git push --force
gh pr create ...

However, if the pull request already exists, the gh CLI fails with an exit code 1, which is indistinguishable from other errors. I want to avoid having to awkwardly parse the stderr output.

Proposed solution

A different exit code to signal that the pull request already exists would allow to check for that case in scripts.

Alternatively, and this is really its own feature request, gh pr create would have a new flag which made it idempotent, editing the PR to match the requested shape when it already exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIgh-prrelating to the gh pr command

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions