I don't understand how do I create a post-receive hook for a specific repository in gitolite (non-root install)
My bare repository contains a website that should copy the working directory to the docRoot
(GIT_WORK_TREE=/path/htdocs git checkout -f
) on update
Before gitolite, I would just update the hook for the specific repository.
Gitolite documentation mentions that all hooks should be at hooks/common
so I don't understand how it works.
What should be the name of hooks, where it should be located and how it's structure should be changed (if it should)?
Update July 2013: what follows is for gitolite V2 (or 'g2'), which was the version used by the OP at the time (November 2011).
Update August 2013, with the latest gitolite 3.x: You now have official specific repo hook:
it's basically just creating a symlink in
<repo.git>/hooks
pointing to some file inside$rc{LOCAL_CODE}/hooks/repo-specific
(except thegitolite-admin
repo)
All hooks in gitolite/hooks/common
are replicated in all repositories managed by Gitolite, as detailed in the hook propagation documentation.
That means your hook script must take specific action depending on the repo which execute said hook.
You can either use the $GL_REPO
variable (which gitolite set and pass to all its scripts for any git command it receives).
Or you can use some git configuration registered on the gitolite server, like the mirroring hook does. See the post-receive.mirrorpush
hook.
The OP Eyal R adds in the comments:
But I still don't understand how it is done (I understand that
$GL_REPO
is used to determine which repo I am updating but I'm missing the practical part).
I have created a file calledpost-receive.test
withecho "test"
, put it in$HOME/gitolite/hooks/common
, rangl-setup
, ran push from workstation - nothing happens (no "test
" output)
To which I replied:
The hook should appear in the
hook
directory of your repo on the gitolite server as a link, linking back to the.gitolite/common/hook
. Note that it should be in$HOME/.gitolite/common/hook
, not/gitolite
.
The OP confirms the missing dot was the issue.
The process to add an hook is detailed in Hook propagation in gitolite, and their usage in "Using Hooks".