A new Git hook to keep the games code clean!

What is a Git hook?

Git hooks are scripts that Git executes before or after events such as: commit, push, and receive. Git hooks are a built-in feature – no need to download anything. Git hooks are run locally. [1]

The new pre-commit hook for gnome-chess!

We now have a new git pre-commit hook for gnome-chess which would get into a games common infrastructure pretty soon!  ^(^

This hook basically checks if your code change complies with the gnome coding guidelines [2] whenever you try to commit. The reason I wrote this is because I also work on projects outside GNOME and it’s really hard to cope up with different coding conventions.

How does it help?

The advantage of this hook is that the reviewers need not worry about looking for nitpicks in the code and can check the logic right away. This would save everyone’s time, and make the review process cleaner and more productive.

Here is an example

Screen Shot 2015-03-10 at 8.44.47 pm

Like it? Want to add this to a project?

Simple! Just 2 steps!

Step-1  Copy over the python pre-commit script[3] to your repository, I chose to make a ‘scripts’ folder and added it in there.

Screen Shot 2015-03-10 at 8.36.58 pm

Step-2 :  Make sure your autogen.sh copies the script over to the git-hooks in your project.

* Read the README[3] for more details.


 

Special thanks to Michael Catanzaro for his inputs from time to time!

[1]: Git – Git Hooks
[2]: Gnome Programming Guidelines
[3]: GitHub repository: Gnome-Code-Guideline-Checker