4

The only thing I found in Gitolite's manual on hooks, was:

If you want to add your own hook, it's easy as long as it's not the 'update' hook. Just add it to $HOME/.gitolite/hooks/common and run gitolite setup.

However, I would also like to track the changes made to these hooks, with the possibility to revert to an older version if needed (auditing functionality is cited as one of the big advantages of using Gitolite). So, basically, I was expecting something like having to add a hooks folder in my gitolite-admin clone, and then pushing the hooks to the server (like you do with the config or adding a public key).

Does this make sense? Is it possible?

Rijk
  • 11,032
  • 3
  • 30
  • 45

2 Answers2

4

Those hooks can be added in your gitolite-admin repo (gitolite-admin/hooks/common) and push back to the Gitolite server.
So they are versioned. (At least that was the case with Gitolite V2, I'll have to check with Gitolite V3)


It turns out, it does work, except the OP Rijk reports:

The problem was an error in my conf, that stopped the setup program.
Commented out that line, and the triggers are installed properly

It was this line in my gitolite.conf:

config hooks.showrev = "git log -1 --name-status --format='%%h (%%ad) ------------------------------%%n%%n%%B' %s". 

Don't know why, but triggered the following error:

FATAL: bad value 'git log -1 --name-status --format='%%h (%%ad) ------------------------------%%n%%n%%B' %s'. 

Commented it out for now, will probably rewrite the post-receive-email script later on.


The OP Rijk's current solution:

The solution I currently have for this on Gitolite v3 is to:

  • put things in gitolite-admin/local-code/hooks/common
  • and then on the server put a full-path symlink to the relevant items within $HOME/.gitolite/hooks/common.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Nope doesn't work. The hook *is* pushed to the server (ends up in `~/.gitolite/hooks/common`, although unexecutable), but it's not copied/linked to the repositories under Gitolite, not even after manually running `gitolite setup`. Am I doing something wrong? – Rijk May 03 '12 at 08:47
  • @Rijk just to check, what version of gitolite are you using? – VonC May 03 '12 at 08:49
  • The latest (g3). I downloaded it this week. – Rijk May 03 '12 at 08:58
  • Sorry, never mind! The problem was an error in my conf, that stopped the setup program. Commented out that line, and the triggers are installed properly. Thanks! – Rijk May 03 '12 at 09:22
  • @Rijk Excellent. Glad I could help. Could you just comment on what line we should be mindful of in the conf file? – VonC May 03 '12 at 09:37
  • It was this line in my `gitolite.conf`: `config hooks.showrev = "git log -1 --name-status --format='%%h (%%ad) ------------------------------%%n%%n%%B' %s"`. Don't know why, but triggered the following error: `FATAL: bad value 'git log -1 --name-status --format='%%h (%%ad) ------------------------------%%n%%n%%B' %s'`. Commented it out for now, will probably rewrite the post-receive-email script later on. – Rijk May 03 '12 at 09:46
  • @Rijk Thank you for this feedback. I have included it in the answer for more visibility. – VonC May 03 '12 at 10:29
  • I do have to manually make it executable each time after I push a new version of the hook. For some reason Gitolite doesn't do this. – Rijk May 11 '12 at 08:30
  • @Rijk for chmod issue, check your UMASK value (http://stackoverflow.com/questions/5455070/permission-problems-with-git-sharedrepository/5455127#5455127) in case it has any bearing. – VonC May 11 '12 at 08:53
  • Can you please clarify where you actually ended up installing your custom hooks? I'm running Gitolite v3 and when I try adding gitolite-admin/hooks/common and push, Gitolite returns the error "remote: FATAL: no files/dirs called 'hooks' or 'logs' are allowed". – Errol Jul 17 '12 at 01:20
  • The solution I currently have for this on Gitolite v3 is to put things in gitolite-admin/local-code/hooks/common and then on the server put a full-path symlink to the relevant items within $HOME/.gitolite/hooks/common . – Errol Jul 17 '12 at 01:41
3

If you take a look at the code in src/lib/Gitolite/Conf.pm, you'll notice that it prints out "bad value" if there is one of the UNSAFE_PATT strings in the value.

And UNSAFE_PATT looks like this (in src/lib/Gitolite/Rc.pm): $UNSAFE_PATT = qr([`~#\$\&()|;<>]);

The issue is your use of parenthesis (and the simplistic parsing in gitolite.conf)

Mischa Taylor
  • 232
  • 1
  • 3