You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@impala.apache.org by Henry Robinson <he...@apache.org> on 2016/09/19 20:36:41 UTC

Git hook to automatically call clang-format

I recently added a git hook to automatically format my patches with
git-clang-format.

It happens on pre-commit. If the commit is --amend, the script chooses
HEAD~1 to compare against instead of HEAD.

The script is here:

https://gist.github.com/henryr/e89f9724eb85a6d5ea48ff0027f36793

If you want to try it yourself (caveat emptor):

wget
https://gist.githubusercontent.com/henryr/e89f9724eb85a6d5ea48ff0027f36793/raw/cb9316ddeceedff798a143ddaa8d9640ec566da3/pre-commit
-O ${IMPALA_HOME}/.git/hooks/pre-commit
chmod +x ${IMPALA_HOME}/.git/hooks/pre-commit

(Warning, may overwrite any existing pre-commit hook you have).

If we all get to using this or something similar, we'll cut down on all the
review back-and-forth about style and formatting issues, which has to be
worth the time it takes to try out this script.

Henry

Re: Git hook to automatically call clang-format

Posted by Henry Robinson <he...@cloudera.com>.
This one works a bit better for me, YMMV:

wget
https://gist.githubusercontent.com/henryr/e89f9724eb85a6d5ea48ff0027f36793/raw/2dd7888d7494cc4d38fb3f51581b503bf25b6c7c/pre-commit
 -O ${IMPALA_HOME}/.git/hooks/pre-commit



On 19 September 2016 at 14:46, Henry Robinson <he...@cloudera.com> wrote:

> Uhhh, scratch that - this doesn't actually commit the changes. I'll work
> on a better version and post it when ready.
>
> On 19 September 2016 at 13:36, Henry Robinson <he...@apache.org> wrote:
>
>> I recently added a git hook to automatically format my patches with
>> git-clang-format.
>>
>> It happens on pre-commit. If the commit is --amend, the script chooses
>> HEAD~1 to compare against instead of HEAD.
>>
>> The script is here:
>>
>> https://gist.github.com/henryr/e89f9724eb85a6d5ea48ff0027f36793
>>
>> If you want to try it yourself (caveat emptor):
>>
>> wget https://gist.githubusercontent.com/henryr/e89f9724eb85a6d5ea
>> 48ff0027f36793/raw/cb9316ddeceedff798a143ddaa8d9640ec566da3/pre-commit
>> -O ${IMPALA_HOME}/.git/hooks/pre-commit
>> chmod +x ${IMPALA_HOME}/.git/hooks/pre-commit
>>
>> (Warning, may overwrite any existing pre-commit hook you have).
>>
>> If we all get to using this or something similar, we'll cut down on all
>> the review back-and-forth about style and formatting issues, which has to
>> be worth the time it takes to try out this script.
>>
>> Henry
>>
>
>
>
> --
> Henry Robinson
> Software Engineer
> Cloudera
> 415-994-6679
>



-- 
Henry Robinson
Software Engineer
Cloudera
415-994-6679

Re: Git hook to automatically call clang-format

Posted by Henry Robinson <he...@cloudera.com>.
Uhhh, scratch that - this doesn't actually commit the changes. I'll work on
a better version and post it when ready.

On 19 September 2016 at 13:36, Henry Robinson <he...@apache.org> wrote:

> I recently added a git hook to automatically format my patches with
> git-clang-format.
>
> It happens on pre-commit. If the commit is --amend, the script chooses
> HEAD~1 to compare against instead of HEAD.
>
> The script is here:
>
> https://gist.github.com/henryr/e89f9724eb85a6d5ea48ff0027f36793
>
> If you want to try it yourself (caveat emptor):
>
> wget https://gist.githubusercontent.com/henryr/
> e89f9724eb85a6d5ea48ff0027f36793/raw/cb9316ddeceedff798a143ddaa8d96
> 40ec566da3/pre-commit -O ${IMPALA_HOME}/.git/hooks/pre-commit
> chmod +x ${IMPALA_HOME}/.git/hooks/pre-commit
>
> (Warning, may overwrite any existing pre-commit hook you have).
>
> If we all get to using this or something similar, we'll cut down on all
> the review back-and-forth about style and formatting issues, which has to
> be worth the time it takes to try out this script.
>
> Henry
>



-- 
Henry Robinson
Software Engineer
Cloudera
415-994-6679