From patchwork Sun Apr 26 22:23:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3550 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AC0A4603FC for ; Mon, 27 Apr 2020 00:23:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NvQeCTmh"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2D4044F7 for ; Mon, 27 Apr 2020 00:23:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587939821; bh=Mb8VBFapOHziM9sQ9i2/35gxgh/cCY0C1r9Qk7BWgjE=; h=From:To:Subject:Date:From; b=NvQeCTmhhzA0EJdRCxvoLbLt8PcxuFAAkvUSQYYxYGq4TR6l+XzG0HLHdvHdlguvd gIgWuNgGvxDwdBI97cjhPqx5DMWKgzlR4AzFWQVF0AcX9crfl6Qiisxs5/CQCVhi77 l/cLofh2NUVlddfqihI1pbZvfcbdLxHA5/Acwzss= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Apr 2020 01:23:23 +0300 Message-Id: <20200426222323.17245-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] utils: hooks: pre-push: Catch commits without committer's SoB 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: Sun, 26 Apr 2020 22:23:41 -0000 Improve the pre-push git hook script to reject commits without the committer's Signed-off-by line. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Kieran Bingham --- utils/hooks/pre-push | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/utils/hooks/pre-push b/utils/hooks/pre-push index 34906ddee5ed..0eb8f5ce193d 100755 --- a/utils/hooks/pre-push +++ b/utils/hooks/pre-push @@ -32,12 +32,35 @@ do range="$remote_sha..$local_sha" fi + # # Find invalid commits. - commit=$(git rev-list -n 1 --grep '^---' "$range") - if [ -n "$commit" ] + # + errors=0 + for commit in $(git rev-list "$range") + do + msg=$(git cat-file commit "$commit") + + # 1. The commit message shall not contain a local changelog. + if echo "$msg" | grep -q '^--- *$' + then + echo >&2 "Found local changelog in commit $commit" + errors=$((errors+1)) + fi + + # 2. The commit message shall have a Signed-off-by line + # corresponding the committer. + committer=$(echo "$msg" | grep '^committer ' | head -1 | \ + cut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev) + if ! echo "$msg" | grep -F -q "Signed-off-by: ${committer}" + then + echo >&2 "Missing committer Signed-off-by in commit $commit" + errors=$((errors+1)) + fi + done + + if [ $errors != 0 ] then - echo >&2 "Found local changelog in $local_ref, not pushing" - echo >&2 "Check commit $commit" + echo >&2 "Found $errors errors in $local_ref, not pushing" exit 1 fi done