Using irker (CIA replacement) and gitolite

I’ve recently switched to Gitolite for my git repository management.
So far, it’s been a great experience: setting it up is easy, and managing it is a pleasure.

I am using a feature where a simple push to a path will create the repository if it does not exist (the only hosting service allowing this is Baregit, the others require using their horrible web interfaces). Not that running git init --bare is such a burden.

The other very nice aspect is that the repositories configuration is done by flat files, and those files are in a git repository.

Now, I used to rely heavily on CIA, which is now broken and will probably never come back. Enters irker, a decentralized notification system focused on IRC.
irker requires that you set up every repository with its hook, and configure that hook.
With simple git hosting, I would have to do that for each repository; but gitolite has a nice feature allowing you to change any local git config value from the central conf/gitolite.conf file.

You first have to add the values to a whitelist. Edit ~/.gitolite.rc and add the following line:

$GL_GITCONFIG_KEYS = "irker.project irker.repo irker.channels";

You might want to add more keys later.

The second step is to configure irker in conf/gitolite.conf:

repo    public/laurentb/gentoo-overlay
        config irker.project = laurentb-gentoo-overlay
        config irker.repo = laurentb/gentoo-overlay
        config irker.channels = "irc://srv1/chan1,irc://"

Commit, push, and the configuration of the repository will be updated.

You can configure other aspects of irker globally by putting them in the ~/.gitconfig of the gitolite user. For some typical CIA-like config, you would use:

    color = mIRC
    cialike = 60

The last step is to install the hook on all repositories. Fortunately, gitolite can do this too. By default, it should have in ~/.gitolite.rc:

$UPDATE_CHAINS_TO = "hooks/update.secondary";

This hook is editable in ~/.gitolite/hooks/common/update.secondary, and is empty by default.
A simple hook would be:

irkerhook --refname=${refname} $(git rev-list --reverse ${old}..${new})
exit 0

You may need to adjust the path to your irkerhook script.

This is going to run irker on every repository. If you don’t want that, you can use a configuration variable to restrict it; I reuse irker.project. With the following example, irker does not run if the project value is empty:

if [ -n $(git config --get irker.project) ]; then
    irkerhook --refname=${refname} $(git rev-list --reverse ${old}..${new})
exit 0

Your system is now ready to notify IRC whenever commits are pushed. Keep in mind the advanced CIA rules are still possible, using the filter hook feature.

I encountered encoding issues because the locale variables were not set by gitolite; you might encounter this problem too. The solution is to set LANG and LC_ALL manually in the script. Put this at the top:

export LC_CYTPE="en_US.utf8" LANGUAGE="en_US.utf8"
This entry was posted in Python, Sysadmin and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>