From patchwork Sat Jan 18 20:00:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne X-Patchwork-Id: 2680 Return-Path: Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E752460455 for ; Sat, 18 Jan 2020 21:02:56 +0100 (CET) Received: from nicolas-tpx395.localdomain (unknown [IPv6:2002:c0de:c115:0:66fc:8b:2a38:8313]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: nicolas) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 9B0052911C1; Sat, 18 Jan 2020 20:02:54 +0000 (GMT) From: Nicolas Dufresne To: libcamera-devel@lists.libcamera.org Cc: Nicolas Dufresne , Laurent Pinchart Date: Sat, 18 Jan 2020 15:00:15 -0500 Message-Id: <20200118200015.16531-7-nicolas@ndufresne.ca> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200118200015.16531-1-nicolas@ndufresne.ca> References: <20200118200015.16531-1-nicolas@ndufresne.ca> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 6/6] checkstyle: Add a pre-commit hook script X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jan 2020 20:02:57 -0000 From: Nicolas Dufresne 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 Reviewed-by: Laurent Pinchart --- utils/hooks/pre-commit | 18 ++++++++++++++++++ 1 file changed, 18 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..47fcbc8 --- /dev/null +++ b/utils/hooks/pre-commit @@ -0,0 +1,18 @@ +#!/bin/sh + +# 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/pre-commit .git/hooks/pre-commit + +if ps -ocommand= -p $PPID | grep -- "--amend" +then + args="--amend" +else + args="--staged" +fi + +./utils/checkstyle.py $args