[{"id":3509,"web_url":"https://patchwork.libcamera.org/comment/3509/","msgid":"<20200118180609.GE5095@pendragon.ideasonboard.com>","date":"2020-01-18T18:06:09","subject":"Re: [libcamera-devel] [PATCH v3 6/6] checkstyle: Add a pre-commit\n\thook script","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nicolas,\n\nThank you for the patch.\n\nOn Fri, Jan 17, 2020 at 10:54:48PM -0500, Nicolas Dufresne wrote:\n> From: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n> \n> This adds support for pre-commit hook workflow. In pre-commit hook we\n> check the style on the changes currently staged or the combination\n> of the index and the last commit if \"git commit --amend\" is being used.\n> \n> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n> ---\n>  utils/hooks/pre-commit | 17 +++++++++++++++++\n>  1 file changed, 17 insertions(+)\n>  create mode 100755 utils/hooks/pre-commit\n> \n> diff --git a/utils/hooks/pre-commit b/utils/hooks/pre-commit\n> new file mode 100755\n> index 0000000..7a5554d\n> --- /dev/null\n> +++ b/utils/hooks/pre-commit\n> @@ -0,0 +1,17 @@\n> +#!/bin/sh\n> +\n> +# Execute the checkstyle script after committing any code. This allows the\n> +# commit to succeed, but ensures that the developer is aware of any potential\n> +# issues immediately, and can resolve them and fix rapidly with:\n> +#   git commit --amend\n\nThis isn't correct for the pre-commit hook. I propose\n\n# Execute the checkstyle script before committing any code. This will fail the\n# commit in case of style issues, ensuring that the developer will notice them.\n# The pre-commit hook can be bypassed with git commit -n to ignore selective\n# changes.\n\n> +#\n> +# To utilise this hook, install this file with:\n> +#   cp utils/hooks/post-commit .git/hooks/post-commit\n\ns/post/pre/g\n\n> +\n> +args=\"--staged\"\n\nHow about dropping this line and adding\n\n> +if ps -ocommand= -p $PPID | grep -- \"--amend\"\n> +then\n> +   args=\"--amend\"\n\nelse\n\targs=\"--staged\"\n\n> +fi\n\nAlso, please use tabs for indentation.\n\n> +\n> +./utils/checkstyle.py $args\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4CFEC60455\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 Jan 2020 19:06:24 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C1FB097A;\n\tSat, 18 Jan 2020 19:06:23 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1579370783;\n\tbh=6GBHI7cwCOrxKIir/v41Ow9ns9aed+zNeNDXgcj+Df8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=pgwqMtcrLEVF/SLFVZIau5qdnUcn8MR4rGW5igm6/SFBgn97tySL2FXofN2ug8L3t\n\tpi26OBnKWc5pDJiJAGtdKcgn9UzqKzaV0YSR6nJWtRk6iGXGYuQky48AGQjxjB6O80\n\tvWpMM8egt2uUgVerDrzok3hsAr4V3hDNnywhiGAo=","Date":"Sat, 18 Jan 2020 20:06:09 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Nicolas Dufresne <nicolas@ndufresne.ca>","Cc":"libcamera-devel@lists.libcamera.org,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>","Message-ID":"<20200118180609.GE5095@pendragon.ideasonboard.com>","References":"<20200118035448.230530-1-nicolas@ndufresne.ca>\n\t<20200118035448.230530-7-nicolas@ndufresne.ca>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200118035448.230530-7-nicolas@ndufresne.ca>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 6/6] checkstyle: Add a pre-commit\n\thook script","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sat, 18 Jan 2020 18:06:24 -0000"}}]