Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to disable git commit when the server time reaches 11am and re-enable when it reaches 2pm?

Or disable git push to all but a select number of users

share|improve this question
    
I doubt it, unless you rewrite the binary file –  Lucas Kauffman Apr 13 '12 at 17:59
    
yeah, thats the plan i was going to take, if git didnt have a built in way of doing this –  Ascherer Apr 13 '12 at 18:01
add comment

3 Answers 3

up vote 7 down vote accepted

Wow you are going to rewrite the whole binary!?!? How about you replace /usr/bin/git with a script instead, and have the script deny commits based on server time.

share|improve this answer
2  
lol! This answer is definitely a prime example of Occam's Razor and it is what I feel to be the correct one. –  WerkkreW Apr 13 '12 at 18:15
2  
hooks are way better way –  poige Apr 13 '12 at 18:37
    
hooks dont seem to give me as much control as we need –  Ascherer Apr 13 '12 at 18:53
    
hook is the same level of control than a changed binary... /home/myuser/bin/git-i-compiled-on-my-own-without-your-restrictions... Git is distributed, use that! Have a gitolite running that only allows your user to write to the master branch, give other users there own "branch areas", let them clone and on there localCopy they can do whatever the heck they want, you're the one merging it to master... Just use the tools, its all there! strg+f for access –  Tabakhase Apr 13 '12 at 19:02
    
not rewriting/changing the binary. This solution is better for our setup. We already have a distributed system, but our users (some of them idiots) are messing up out "hotfix" branch (which is where they are supposed to be anyways) –  Ascherer Apr 13 '12 at 20:08
add comment

For the git push part "pre-receive hook" in the remote repo.

The "not commit" is not possible in a secure way, so whatever you choose the user 'can' bypass it!

a) the "pre-commit hook" in git.

b) alias git in your .profile and put a wrapper in between that prints a "no" or bypasses to git with the original arguments.

--

Or are you looking for remote repos with permissions & co? Check out gitolite

share|improve this answer
add comment

I haven't tested this, but what happens if you remove write permission of git's repo folders to the users and groups which effectively do the change? I guess git will complain somehow and tell the user it cannot execute the command successfully, but pulling and checkout should still be possible.

The correct user, of course, depends on the way how the repo is accessed. In case of push over http this might be the webserver's user and group which is, e. g., called www-data on my Debian with Apache.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.