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.

I have a script on the client machine that adds the necessary configuration stuff to gitosis.conf on the server. I'm able to push and everything works correctly.

However, I want to add a post-receive hook so that when the repository is first pushed, some particular action occurs. I tried to add it to the local repository before the first version (in .git/hooks) but the hook wasn't transferred to the server on a push.

How can I do this? There is no repository in the /srv/gitosis/repositories directory until the initial push.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Git uses templates to set up new repositories. I don't know if Gitorious uses these same templates, but it's worth checking out. On my system they exist at /usr/local/share/git-core/templates/hooks.

share|improve this answer
    
I checked out the gitosis documentation and it's extremely sparse. Is there a way to add a template conditionally? –  dave paola Aug 19 '10 at 0:13

Hooks are not pushed to server via git push. Otherwise, this would arise a severe security issue: anyone can push code that is executed on your server with higher privileges.

To workaround the issue, you may just copy the hook into the created directory, and run it manually after your first push:

GIT_DIR=. hooks/post-receive

You'll have to do this only once.

share|improve this answer
    
I'm trying to do this programatically though. These repositories are created by a script. –  dave paola Aug 18 '10 at 6:25
    
@davezor, well, the most obiovus way then would be to fix gitosis itself, so it stores per-repository hooks inside gitosis repository, and saves them to the proper folders. I think such functionality (unless it's already implemented) would be useful to community as well. –  Pavel Shved Aug 18 '10 at 6:32

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.