[libcamera-devel] [PATCH v2 6/6] checkstyle: Add a pre-commit hook script

Nicolas Dufresne nicolas.dufresne at collabora.com
Fri Jan 17 23:59:13 CET 2020


Le samedi 18 janvier 2020 à 00:20 +0200, Laurent Pinchart a écrit :
> Hi Nicolas,
> 
> Thank you for the patch.
> 
> On Fri, Jan 17, 2020 at 02:17:33PM -0500, Nicolas Dufresne wrote:
> > From: Nicolas Dufresne <nicolas.dufresne at collabora.com>
> > 
> > This adds support for pre-commit hook workflow. In pre-commit hook we
> > check the style on the changes currently staged or the combination
> > of the index and the last commit if "git commit --amend" is being used.
> > 
> > Signed-off-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>
> > ---
> >  utils/hooks/pre-commit | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> >  create mode 100755 utils/hooks/pre-commit
> > 
> > diff --git a/utils/hooks/pre-commit b/utils/hooks/pre-commit
> > new file mode 100755
> > index 0000000..be2f8b3
> > --- /dev/null
> > +++ b/utils/hooks/pre-commit
> > @@ -0,0 +1,17 @@
> > +#!/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 with:
> > +#   cp utils/hooks/post-commit .git/hooks/post-commit
> > +
> > +args="--staged"
> > +if ps -ocommand= -p $PPID | grep -- "--amend"
> > +then
> > +   commit="--amend"
> 
> commit isn't used below... Did you mean args ? Seems more testing is
> needed ;-)

That one I didn't have locally, fixing.

> 
> > +fi
> > +
> > +./utils/checkstyle.py $args



More information about the libcamera-devel mailing list