xarray
xarray copied to clipboard
Require a pull request before merging to main
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:
Describe alternatives you've considered
No response
Additional context
No response
I've also accidentally done this before and would also prefer a guard against my own trigger finger :sweat_smile:
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 usualgit push
will push to your fork (instead of editing.git/config
directly you can also usemagit
'sP C
menu, if you use emacs andmagit
):
[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 withgit push --no-verify
)
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.
I just toggled the "Require a pull request before merging" option