Message ID | 20200118035448.230530-7-nicolas@ndufresne.ca |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Nicolas, Thank you for the patch. On Fri, Jan 17, 2020 at 10:54:48PM -0500, Nicolas Dufresne wrote: > From: Nicolas Dufresne <nicolas.dufresne@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@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..7a5554d > --- /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 This isn't correct for the pre-commit hook. I propose # Execute the checkstyle script before committing any code. This will fail the # commit in case of style issues, ensuring that the developer will notice them. # The pre-commit hook can be bypassed with git commit -n to ignore selective # changes. > +# > +# To utilise this hook, install this file with: > +# cp utils/hooks/post-commit .git/hooks/post-commit s/post/pre/g > + > +args="--staged" How about dropping this line and adding > +if ps -ocommand= -p $PPID | grep -- "--amend" > +then > + args="--amend" else args="--staged" > +fi Also, please use tabs for indentation. > + > +./utils/checkstyle.py $args Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
diff --git a/utils/hooks/pre-commit b/utils/hooks/pre-commit new file mode 100755 index 0000000..7a5554d --- /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 + args="--amend" +fi + +./utils/checkstyle.py $args