I wrote long ago about the
trouble I had with Net::XMPP
while setting up a notification hook for Archiveopteryx, but I didn't
think anyone would find the script itself particularly interesting. But
people have asked me about it, so here it is.
I wrote a Perl script named
that sends a message via XMPP (Jabber) every time something is committed
to a repository. It depends on the Net::Jabber module (and perhaps also
Net::DNS, but see below). You can download and install it directly as a
$ cd .git/hooks
$ wget -O post-receive \
$ chmod +x post-receive
(I tend to just call this from a separate .git/hooks/post-receive
script, because I sometimes need to do other things in the hook, like
You have to tell the hook whom to send notifications to, and optionally
which branches to pay attention to (failing which it pays attention only
$ git config hooks.notify.branches 'master next foo'
$ git config hooks.notify.recipients 'email@example.com firstname.lastname@example.org'
Finally, you have to edit the script to set the correct jid and password
to use when sending the notifications, and the name used to identify the
repository to the recipients:
my $repo = "foo.git";
my $JID = 'email@example.com';
my $password = "cd2e1f7d4a8500f394771b620a85aa5e";
If you want, you can also edit the "git log" command in the script to
include whatever information you want in each change description (like
--diffstat and so on).
That's all there is to it. Let me know if you have any problems getting
it to work.
(If you want commit notifications by email instead, look at the
post-receive-notify-email script in Git contrib/hooks.)
The old Net::XMPP bug
If the XMPP server you want to connect to in order to send notifications
has the same hostname as the jid you want to use, you're fine. In other
words, if you want to send a notification as firstname.lastname@example.org and your
XMPP server is reachable at example.org, you're safe from the bug.
If XMPP service for your domain is provided by a different server, i.e.
you want to send the notification as email@example.com, and example.org
has SRV records that point you to xmpp.example.net, then you will need
to install Net::DNS and patch Net::XMPP (which is a lower-level
dependency of the Net::Jabber module) to cope.
my earlier post for
details about the problem and