-
-
Notifications
You must be signed in to change notification settings - Fork 360
Optional hooks to prevent committing/pushing to master #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In case the community likes that PR: I would move the explanation into the Wiki of the this GitHub repo. I think the Wiki is a better place for developer oriented explanations/content. |
We were thinking about creating a directory under the project root that should hold scripts like update_site.sh. This is probably a good opportunity to act on that. I'd call it tools or scripts, although I personally lean towards tools because it's more flexible. What do you think? Let me also summon @leios real quick for this one. |
If we get more and more helper scripts/tools, a sub-directory is useful and |
.hooks/pre-push.hook
Outdated
|
||
while read local_ref local_sha remote_ref remote_sha | ||
do | ||
if [ "$remote_ref" = "refs/heads/master" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will cause trouble when you have two remotes, origin and upstream where origin points to a personal fork and upstream points to this repository. When you pull changes from upstream and want to push them to origin to keep your fork up-to-date, this will block the push if I understand correctly.
It should be enough to block commits to master in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. It could be changed to allow the push if refs/remotes/upstream/master
and refs/heads/master
are equal, but if the remote isn't upstream
it fails, and making this bulletproof is simply not worth it.
Also, will these hooks prevent local fast-forward merges into master? |
No, you'll need something like
|
Sounds good at first, but I can imagine this blocking |
Are you referring to the
I don't remember the |
...since it has the undesirable behavior of not allowing push after rebasing against upstream, for example.
Rebasing master onto upstream/master should technically not even be necessary, because there shouldn't be anything to rebase on master in the first place. In that case, even a Anyway, I tested the script and hook and it works as expected. The only thing left is to decide on the directory name for the scripts. |
If this does what we expect, then it prevents people from pushing to their local masters, which means they need to use feature branches. That seems like a good thing. I know I could have used the protection once or twice. I think |
In case anyone wants to prevent themselves from committing to their local master branch or pushing to their own remote master.