---
author: einar
categories:
- KDE
- Linux
comments: true
date: "2011-01-26T11:59:04Z"
slug: improvements-to-the-git-hooks
tags:
- git
- KDE
- Linux
- review board
title: Improvements to the Git hooks
omit_header_text: true
disable_share: true
wordpress_id: 816
---

As you may already know, recently the KDE sysadmins completely overhauled the commit hooks used with the Git infrastructure. Written in Python, they have already brought significant improvements to the current workflows. These hooks include keywords that when specified trigger particular actions: the most used are  to CC specific email addresses (CCMAIL), to CC bug reports (CCBUG) or to close bug reports (BUG).

With the adoption of [Review Board](http://www.reviewboard.org/) to facilitate code reviews, there were also requests for a REVIEW keyword that could close the review requests without asking the submitters to do so manually (which is slow and not always effective). Since the hooks for Git were written in Python, I thought I could give a hand there.

I looked into the Review Board API, which is a simple REST API: tasks are performed with HTTP GET, POST, or PUT. As I didn't want to dive too much into the technicalities, I decided to use a wrapper that would make things easier: [python-rest-client](http://code.google.com/p/python-rest-client/). Once that was in place, it was just a matter of adding some sugar to handle replies, errors and logging. All in 78 lines of code.

Now that the "field tests" passed with flying colors, I'm happy to announce that such a hook exists and is operational for KDE's Git infrastructure. By using the REVIEW keyword at the start of a line, followed by a number, the hook will notify the Review Board instance and close the request. It will also publish a comment stating the commit's SHA1 and the person who did it.

You can take a look at the finished results [in this review request.](http://git.reviewboard.kde.org/r/100270/)

Credits for this also go to Ben "bcooksley" Cooksley for helping with testing and fixes, and Eike "Sho" Hein for helpful suggestions.
