[libcamera-devel] [PATCH] utils: hooks: Provide post-commit hook example to checkstyle.py

Kieran Bingham kieran.bingham at ideasonboard.com
Wed Jan 30 11:59:25 CET 2019


Hi Laurent,

On 23/01/2019 16:16, Laurent Pinchart wrote:
> Hi Kieran,
> 
> On Wed, Jan 23, 2019 at 02:15:47PM +0000, Kieran Bingham wrote:
>> On 22/01/2019 23:32, Laurent Pinchart wrote:
>>> On Tue, Jan 22, 2019 at 07:29:30PM +0000, Kieran Bingham wrote:
>>>> Provide an example post-commit hook which a developer can install, ensuring
>>>> that every commit gets the style checker executed on it.
>>>>
>>>> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
>>>> ---
>>>>  utils/hooks/post-commit | 11 +++++++++++
>>>>  1 file changed, 11 insertions(+)
>>>>  create mode 100755 utils/hooks/post-commit
>>>>
>>>> diff --git a/utils/hooks/post-commit b/utils/hooks/post-commit
>>>> new file mode 100755
>>>> index 000000000000..e992428b11ae
>>>> --- /dev/null
>>>> +++ b/utils/hooks/post-commit
>>>> @@ -0,0 +1,11 @@
>>>> +#!/bin/sh
>>>> +
>>>> +# Execute the checkstyle script after committing any code.  This allows the
>>>
>>> s/  / / or is it on purpose ?
>>
>> That was done by vim's auto-formatter. <esc-gqip>
> 
> Interesting, vim doesn't modify the amount of spaces for me when doing
> reformatting.
> 
>>>> +# commit to succeed, but ensures that the developer is aware of any potential
>>>> +# issues immediately, and can resolve them and fix rapidly with:
>>>> +#   git commit --amend
>>>> +#
>>>> +# To utilise this hook, install this file to:
>>>> +#   .git/hooks/post-commit
>>>
>>> I would say
>>>
>>> # To utilise this hook, install this file to:
>>> #   cp utils/hooks/post-commit .git/hooks/post-commit
>>
>> what about 'ln -s' to keep updates?
> 
> You would need to put lots of trust on the repository for that... I
> wouldn't do it personally, imagine if someone pushed a rm -rf $HOME to
> the script.
> 
>> 'install this file to:' then doesn't flow... so perhaps it would have to
>> read
>>
>> 'install this file with:' or 'by':
> 
> Good point, with and by both work for me.
> 
>> But the point was - I was leaving this operation up to the user.
>>
>>>> +
>>>> +./utils/checkstyle.py
>>>
>>> Are hooks always run from the root of the tree if you run git commit
>>> from a subdirectory ? If not, I'm sure there's a way for the hook to the
>>> the base path.
>>
>> The hook is executed from the root of the tree.
>>
>> You can test by going into any sub-directory and creating a commit.
>> The hook will still successfully run.
> 
> OK, perfect then.
> 
>>> With these issues addressed,
>>>
>>> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

Pushed with the fixes suggested.

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list