Open michaeldejong opened 11 years ago
I've been trying to figure out how to write a post-update
hook so I'll be able to notify a HTTP server.
#!/usr/bin/perl -w
use strict;
use warnings;
use lib $ENV{GL_LIBDIR};
use Gitolite::Hooks::Update
# gitolite update hook
#---------------------------------------------------------------
my $path = `pwd`;
$path =~ s/\/home\/git\/repositories\///;
`curl -s http://<host>/?repo=$path`;
update();
exit 1;
Why PERL? All variables are passed in a hook.
It takes a variable number of parameters, each of which is the name of ref that was actually updated.
https://www.kernel.org/pub/software/scm/git/docs/githooks.html
You can use CURL to do form a POST body in Json and deliver that to a webserver.
REVISION=$2 # or whatever it is
curl -X POST -H "Content-Type: application/json" -d '{"revision":"$REVISION","repo":"xyz"}' http://the.url.com/hook
Perl because, that's what Gitolite is using in the already existing post-update
hook of my testing repo. I can easily switch to bash, but for now it's just to find out how these hooks work and test them. Also, my current aim is just to be able to notify a web server that a certain repository has received a push. It's up to that web server to determine if it's interested in fetching stuff like logs/diffs/branches.
Users should be able to add or remove git hooks for every repository (excluding gitolite-admin). This will probably require Java-Gitolite-Manager to be run on the git server (preferably on the git user).