git-pull-request icon indicating copy to clipboard operation
git-pull-request copied to clipboard

[feature request] Command to push to master and close pull request

Open alamothe opened this issue 5 years ago • 7 comments

Once the pull request is reviewed and approved, our workflow is that the author should merge it. This can be done easily through GitHub UI (there is a "Squash and merge" button).

There are a couple of problems with this:

  • We can't do it through command line.
  • After it's done, the local branch becomes useless. Sometimes people will accidentally continue working in there, thinking it's nw at origin/master which is not the case.

Ideally, we want a command git pull-request --merge which will:

  • Merge into origin/master.
  • Close pull request.
  • Delete local branch.

What are your thoughts?

alamothe avatar Apr 30 '20 22:04 alamothe

Why don't you use https://mergify.io to do that directly from GitHub?

jd avatar May 01 '20 13:05 jd

I still want a command line tool. Does https://mergify.io offer a command line tool to do that?

alamothe avatar May 05 '20 21:05 alamothe

No. Why do you want a command-line tool when you can make things automatic? 🤔

jd avatar May 06 '20 08:05 jd

When a pull request is approved, there are still some final comments left.

It is expected of the author to fix the final comments and merge it themselves (update, push the button in GitHub UI, remember to delete the local branch).

So I am interested in automating the last part.

At least this is our workflow. It would slow us down if we do another round of "request changes" for the final comments which are usually nits.

Thanks for your reply!

alamothe avatar May 06 '20 20:05 alamothe

...By the way, this tool saves us a ton of time and we would be OK to pay for it per user per month as long as it's not too much. Perhaps you can offer it as part of your Mergify package.

alamothe avatar May 06 '20 20:05 alamothe

Thank you, that's nice! Feel free to subscribe to Mergify anyhow, that'll support us and this tool.

I think there are 2 solutions to your issues here:

  1. automatic merge: that really should be Mergify job IMHO. You can do that with a rule like:
- name: automatic merge
  conditions:
    - label=ready-to-merge
    - status-success=your ci system
    - "#approved-reviews-by>=1"
  actions:
    merge:
      method: squash

By using a label, you make sure the author has set this label when it's ready to be merged and that the CI works, etc. You can define finer-grained rules of course, but there's no need for doing anything "local" that way.

  1. Cleaning merged pull requests.

It's actually something I'd love to have too. That could be the job git-pull-request indeed. What'd be useful is to be able to delete local branches when their corresponding PR are merged, or even display their status. That shouldn't be too hard to implement I imagine. 🤔

jd avatar May 07 '20 08:05 jd

It's actually something I'd love to have too. That could be the job git-pull-request indeed. What'd be useful is to be able to delete local branches when their corresponding PR are merged, or even display their status. That shouldn't be too hard to implement I imagine. 🤔

Yes, need exactly this. Sometimes developers will continue working on the local branch by accident, and make a mess locally. Maybe then a feature for git-pull-request to mark a PR with a label you suggested and delete the local branch. Then Mergify can take over.

alamothe avatar May 07 '20 21:05 alamothe