Hub: If the pull request already exists, update the description, and open it in the browser if -o is given

Created on 18 Jan 2018  路  11Comments  路  Source: github/hub

Actually this is two loosely related issues, that come up together due to the way I use this awesome tool.

Repro:

  1. git pull-request -b development -m "OLD MSG" # Pull request is created
  2. git pull-request -b development -o # Invoke again

Expected:

  • the current PR description should be shown in the editor with the possibility to modify it and then update the description of the PR

    • the URL for the preexisting PR should be opened in the browser.

Actual:

Error creating pull request: Unprocessable Entity (HTTP 422)
A pull request already exists for xx:xx
feature

Most helpful comment

This is somehow related to #867, too.

I think having a command like git pull-request --upsert like @arcanis suggested above would solve all the issues. It creates a PR or updates the PR if it exists, does not fail, and still returns the PR's URL.

That would also help a lot in scripts that automatically create PRs.

All 11 comments

Interesting. I'm not sure if we'd want to implement feature 1 (it might violate the principle of least surprise) but feature 2 is definitely interesting if -o was passed. Keeping open as something to think about.

I don't think it would come as a surprise if the current PRs description, etc. would be shown to the user. The top of the file could also contain a comment with the fact that this PR already exists.

It could also be put behind a new option or just ask the user for confirmatoin - PR already exists - edit instead?

I'd be really interested - I'm automating my PR creation, but it's a pain when updating them. At the very least it would be great if hub wasn't crashing when the PR already exists, instead simply printing its current URL. Maybe an --upsert option?

This would be really great. I'm using hub to make it easier to create and submit multiple chained PRs (e.g. to make reviews easier by splitting a feature into more manageable chunks) and it would be splendid if I could edit the PR descriptions with links to the other PRs in the chain.

I think this would be an amazing addition.

If a PR exists on GitHub, get the current PR description and use that as the text in the editor. If a PR does not exist, use the current PR template generated

Twould be nice if we got this functionality just by using hub pull-request

Other things to watch out for is the assignments of labels, reviewers, and assignees. I believe these should be added on to the ones already existing in the PR

This is somehow related to #867, too.

I think having a command like git pull-request --upsert like @arcanis suggested above would solve all the issues. It creates a PR or updates the PR if it exists, does not fail, and still returns the PR's URL.

That would also help a lot in scripts that automatically create PRs.

Any progress on this issue here?

I'm actually looking to automate my pull request but the closest thing i could find to check if the PR exist already is using hub pr list which kinda gets me half way. It will still crash when it tries to open a PR if one already exist.

@ARXChrono You can use hub pr list to query PRs based on different criteria or hub pr show to list an existing PR that belongs to the current branch. You can use the latter to check if a PR exists before opening a new one with hub pull-request.

There is still no command to update a pull request.

@mislav I only see hub pr list and hub pr checkout , I don't think hub pr show is a thing anymore?

@ARXChrono You may need to upgrade https://github.com/github/hub/releases/tag/v2.12.0.

Cross-referencing an earlier, closely related feature request: #1523

Was this page helpful?
0 / 5 - 0 ratings