9

I've read all the documentation about hooks, similar questions and a lot of code but I can't track where is the error in my procedure. I need to install a simple hook in my gitolite installation (made with an rpm package on CentOS) so here is what I did:

To install gitolite (some time ago):

  1. Installed the rpm package
  2. # su - gitolite
  3. $ gl-setup /tmp/fabio.pub (as gitolite user)

Now to install the hook:

  1. Created a sample file post-update with the hook code in ~gitolite/.gitolite/hooks/common and chmod +x on it
  2. run gl-setup /tmp/fabio.pub again as stated here

But nothing happened, the exit status from the latest command is 0, but the hook file is not symlinked in any of the repository. So what's wrong with my procedure? Have I missed something?

Bonus questions:

  1. If I had understood the doc my procedure is the right one? I.e. should I run gl-setup every time I update any hook?
  2. In this way I install the shared hooks in every repository under this gitolite installation, is that right? Can I manually install an hook either as symlink to somewhere or just an executable script only for a given repository? Should I do that manually in the hook folder of the given repository? Should I care of hooks conflicts (i.e. would any custom hook for the single repository block any other shared hook with the same name)?

Don't know if this matters, my gitolite version is 1.5.9.1.

Community
  • 1
  • 1
Fabio
  • 18,856
  • 9
  • 82
  • 114

3 Answers3

1

In Gitolite v3 you may choose where to put your hooks editing LOCAL_CODE variable in .gitolite.rc. See the file source for more options (eg. enabling per repo custom hooks)

Then you put your hooks in the specified dir, make them executable and run gitolite setup --hooks-only.

takeshin
  • 49,108
  • 32
  • 120
  • 164
0

I just found out that if I copy my hook sample in /usr/share/gitolite/hooks/common/ it will be symlinked by gl-setup. Maybe in this package $GL_ADMINDIR variable is not set for some reason. Two bonus questions still stands...

Fabio
  • 18,856
  • 9
  • 82
  • 114
0

you need to add an update.secondary hook in the directory then redeploy with gl-easyinstall. Take a look at the update hook that comes with gitolite. You will see that near the end, it calls update.secondary. If you provide that, it will work.

user229044
  • 232,980
  • 40
  • 330
  • 338
Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • I don't need an update hook, so I don't think this would solve my issue. Plus I've installed from a package, so I think my command is not `gl-easyinstall` but `gl-setup`. – Fabio Aug 29 '11 at 22:10
  • you update hooks in the gitolite clone and then re-run the easy install script. What is the objective of your hook? Most things are done through the update hook. – Adam Dymitruk Aug 29 '11 at 23:20
  • [this is the hook I need](https://github.com/kahseng/redmine_gitolite_hook/blob/master/contrib/hooks/post-receive-redmine_gitolite). I simply can't run `gl-easyinstall` because I don't have a local clone since I've installed gitolite using the [package method](https://github.com/sitaramc/gitolite/blob/pu/doc/1-INSTALL.mkd#_package_method). – Fabio Aug 30 '11 at 00:05
  • I'd reinstall from client. Your script can be adjusted to be an update script. Instead of stdin, your old, new and refspec are going to come as command line args. Easy change. You'll have an easier time updating hooks if you install from the client side. – Adam Dymitruk Aug 30 '11 at 00:41