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

Message ID 20190122192930.10540-1-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel] utils: hooks: Provide post-commit hook example to checkstyle.py
Related show

Commit Message

Kieran Bingham Jan. 22, 2019, 7:29 p.m. UTC
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@ideasonboard.com>
---
 utils/hooks/post-commit | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100755 utils/hooks/post-commit

Comments

Laurent Pinchart Jan. 22, 2019, 11:32 p.m. UTC | #1
Hi Kieran,

Thank you for the patch.

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@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 ?

> +# 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

> +
> +./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.

With these issues addressed,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Kieran Bingham Jan. 23, 2019, 2:15 p.m. UTC | #2
Hi Laurent,

On 22/01/2019 23:32, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> 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@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>

> 
>> +# 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?

'install this file to:' then doesn't flow... so perhaps it would have to
read

'install this file with:' or 'by':

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.

> 
> With these issues addressed,
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Laurent Pinchart Jan. 23, 2019, 4:16 p.m. UTC | #3
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@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@ideasonboard.com>
Kieran Bingham Jan. 30, 2019, 10:59 a.m. UTC | #4
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@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@ideasonboard.com>

Pushed with the fixes suggested.

Patch

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
+# 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
+
+./utils/checkstyle.py