xarray icon indicating copy to clipboard operation
xarray copied to clipboard

Require a pull request before merging to main

Open Illviljan opened this issue 1 year ago • 4 comments

Is your feature request related to a problem?

I was making sure the test in #6832 failed on main, when it did I wrote a few lines in the what's new file but forgot switching back to the other branch and accidentally pushed directly to main. :(

Describe the solution you'd like

I think it's best if we require a pull request for merging. We seem to pretty much do this anyway.

Seems to be this setting if I understand correctly: image

Describe alternatives you've considered

No response

Additional context

No response

Illviljan avatar Jul 26 '22 22:07 Illviljan

I've also accidentally done this before and would also prefer a guard against my own trigger finger :sweat_smile:

TomNicholas avatar Jul 27 '22 05:07 TomNicholas

there are still cases where it would be good to allow pushing to main, the most notable being the release bump / cleanup (but maybe we can temporarily allow pushes for that?).

There's a few settings in git you can use to make this harder, though:

  • set the default push remote for main to your own fork: that way, you can still explicitly push (git push origin main), but the usual git push will push to your fork (instead of editing .git/config directly you can also use magit's P C menu, if you use emacs and magit):
[remote]
    pushDefault = myfork  # to generally avoid pushing to the main repository
[branch "main"]
    pushRemote = myfork  # specifically for main
  • create a pre-push hook that will refuse pushing to main (you can still disable it with git push --no-verify)

keewis avatar Jul 27 '22 08:07 keewis

If this is helpful to anyone, here are some configs I use to: a) avoid opening a browser b) avoid pushing to main

This will push the current branch, and tell GH to merge as soon as test pass. I never feel the need to push to main now; even something like the release cleanup can be done through an PR.

    pub-merge-gh   = !git publish && gh pr create --fill && gh pr merge --auto --squash --delete-branch
    publish        = "!git push --set-upstream origin $(git branch --show-current)"

(the latter can be replaced with push with the latest version of git & [push]; autoSetupRemote = true configs.

max-sixty avatar Jul 27 '22 18:07 max-sixty

I just toggled the "Require a pull request before merging" option

shoyer avatar Jul 28 '22 16:07 shoyer