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

Laurent Pinchart laurent.pinchart at ideasonboard.com
Fri Jan 17 23:20:35 CET 2020


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 ;-)

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

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list