dennogumi/content/post/2011-01-26-improvements-to-the-git-hooks.markdown
Luca Beltrame 64b24842b8
All checks were successful
continuous-integration/drone/push Build is passing
Update all posts to not show the header text
2021-01-13 00:05:30 +01:00

2 KiB

author categories comments date slug tags title omit_header_text disable_share wordpress_id
einar
KDE
Linux
true 2011-01-26T11:59:04Z improvements-to-the-git-hooks
git
KDE
Linux
review board
Improvements to the Git hooks true true 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 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. 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.

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