Qt/Kde coding style and Git tree

Posted on sexta-feira, abril 17th, 2009 at 14:00

Hi all,

today I will post  a script to check and fix Qt/Kde coding style using astyle command in a woking git tree.

#!/bin/bash

astyle --indent=spaces=4 --brackets=linux
      --indent-labels --pad=oper --unpad=paren
      --one-line=keep-statements --convert-tabs
      --indent-preprocessor
      $(git-status | awk -F : '(/modified:/ ||
	/new file:/) && (/.h>/ || /.c>/ ||
	/.cpp>/) {print $2}')

Download the source code here.

So you just need run the script in a working git tree to check and fix Qt coding style.

It will check and fix Qt coding style in all files modified in the git tree.

To force the coding style fix before each commit you can put the script as git’s hook script, putting it in the .git/hooks/pre-commit file of your project.

To enable the pre-commit hook script just run:

$ chmod +x .git/hooks/pre-commit

References:

http://astyle.sourceforge.net/

http://techbase.kde.org/Policies/Kdelibs_Coding_Style

http://git-scm.com/

You can leave a response, or trackback from your own site.

One Response to “Qt/Kde coding style and Git tree”

Leave a Reply