From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 0DD4EA055C;
	Sun, 12 Jun 2022 16:23:26 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id AA9B340150;
	Sun, 12 Jun 2022 16:23:25 +0200 (CEST)
Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com
 [67.231.148.174])
 by mails.dpdk.org (Postfix) with ESMTP id B60A0400EF
 for <dev@dpdk.org>; Sun, 12 Jun 2022 16:23:23 +0200 (CEST)
Received: from pps.filterd (m0045849.ppops.net [127.0.0.1])
 by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25CCUdWb008560;
 Sun, 12 Jun 2022 07:23:22 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;
 h=from : to : cc :
 subject : date : message-id : mime-version : content-transfer-encoding :
 content-type; s=pfpt0220; bh=sy7hPtlNyWIOn9E89rVgU63eejZ0Q7Zz3mxgSSSvvI4=;
 b=fXrQtU5sXjt4Eg8lDbRTQ59kvDe5ywf/kTEoyl22+zLuZQpdZNU5EqCIdxqaz41vvUmu
 588EccUjAwltLO/kK9gfGZVpIrBQ1Ew/zjNdCKoHMdbjESKlloSb4swG3BOJqYd6DHaW
 q1AGcohmfQj+zn66Qm7lkjOG5LSqmxmewBwnCUoIKIUQeCpYtPuVb5ICcxb3gvHkFH9o
 wBzcZd7eS74xgM0Xm1GrQ6XSL11S/PWfw5yhMhw65bxJ+IrlDe+TPi/mEJl6CfFSZSB1
 tGfTCNgOk60xd0IdDlt8wbd1Z0tda7RQN3BrUMLmI7QEBqqn9EzUVyyJk9c+5/n+9/4O Ag== 
Received: from dc5-exch02.marvell.com ([199.233.59.182])
 by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3gmrds395f-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);
 Sun, 12 Jun 2022 07:23:22 -0700
Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com
 (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18;
 Sun, 12 Jun 2022 07:23:20 -0700
Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com
 (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend
 Transport; Sun, 12 Jun 2022 07:23:20 -0700
Received: from localhost.localdomain (unknown [10.28.34.39])
 by maili.marvell.com (Postfix) with ESMTP id 336363F7074;
 Sun, 12 Jun 2022 07:23:18 -0700 (PDT)
From: <jpalider@marvell.com>
To: <dev@dpdk.org>
CC: <thomas@monjalon.net>, <david.marchand@redhat.com>, Jakub Palider
 <jpalider@marvell.com>
Subject: [PATCH] devtools: ensure proper tag sequence
Date: Sun, 12 Jun 2022 16:23:07 +0200
Message-ID: <20220612142307.938570-1-jpalider@marvell.com>
X-Mailer: git-send-email 2.25.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Proofpoint-GUID: aD8MUb1JLrLS3TVfUgYLLeMV0YyQ9_dF
X-Proofpoint-ORIG-GUID: aD8MUb1JLrLS3TVfUgYLLeMV0YyQ9_dF
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514
 definitions=2022-06-12_06,2022-06-09_02,2022-02-23_01
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

From: Jakub Palider <jpalider@marvell.com>

This change to log checking procedure ensures that all
tags are in proper order.
The order of tags is as follows:
 * Coverity issue
 * Bugzilla ID
 * Fixes
 * Cc
 * <BLANK LINE>
 * Suggested-by
 * Reported-by
 + Signed-off-by
 * Acked-by
 * Reviewed-by
 * Tested-by
where:
 * => 0 or more than one instance possible
 + => more than once instance possible
In order to satisfy the above requirements an extra check
is performed for obligatory tags.

Signed-off-by: Jakub Palider <jpalider@marvell.com>
Change-Id: I58d94fecddd5f978e0567b04f72bd2dc1c0b8a08
---
 devtools/check-git-log.sh           | 51 +++++++++++++++++++++++++++++
 doc/guides/contributing/patches.rst | 25 ++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/devtools/check-git-log.sh b/devtools/check-git-log.sh
index 23c6a7d9bb..0d8fff94ee 100755
--- a/devtools/check-git-log.sh
+++ b/devtools/check-git-log.sh
@@ -54,6 +54,7 @@ fixes=$(git log --format='%h %s' --reverse $range | grep -i ': *fix' | cut -d' '
 stablefixes=$($selfdir/git-log-fixes.sh $range | sed '/(N\/A)$/d'  | cut -d' ' -f2)
 tags=$(git log --format='%b' --reverse $range | grep -i -e 'by *:' -e 'fix.*:')
 bytag='\(Reported\|Suggested\|Signed-off\|Acked\|Reviewed\|Tested\)-by:'
+exttag='Coverity issue:\|Bugzilla ID:\|Fixes:\|Cc:'
 
 failure=false
 
@@ -203,6 +204,56 @@ done)
 [ -z "$bad" ] || { printf "Is it candidate for Cc: stable@dpdk.org backport?\n$bad\n"\
 	&& failure=true;}
 
+# check tag sequence
+bad=$(for commit in $commits; do
+	body=$(git log --format='%b' -1 $commit)
+	echo "$body" |\
+	grep -o -e "$exttag\|^[[:blank:]]*$\|$bytag" | \
+	# retrieve tags only
+	cut -f1 -d":" |\
+	# it is okay to have several tags of the same type but for processing
+	# we need to squash them
+	uniq |\
+	# make sure the tags are in the proper order as presented in SEQ
+	awk -v cmt="$commit" 'BEGIN{
+		SEQ[0] = "Coverity issue";
+		SEQ[1] = "Bugzilla ID";
+		SEQ[2] = "Fixes";
+		SEQ[3] = "Cc";
+		SEQ[4] = "^$";
+		SEQ[5] = "Suggested-by";
+		SEQ[6] = "Reported-by";
+		SEQ[7] = "Signed-off-by";
+		SEQ[8] = "Acked-by";
+		SEQ[9] = "Reviewed-by";
+		SEQ[10] = "Tested-by";
+		latest = 0;
+	}
+	{
+		for (seq = 0; seq < length(SEQ); seq++) {
+			if (match($0, SEQ[seq])) {
+				if (seq < latest) {
+					print "\tCommit " cmt " (" $0 ":)";
+					break;
+				} else {
+					latest = seq;
+				}
+			}
+		}
+	 }'
+done)
+[ -z "$bad" ] || { printf "Wrong tag order: \n$bad\n"\
+	&& failure=true;}
+
+# check required tag
+bad=$(for commit in $commits; do
+	  body=$(git log --format='%b' -1 $commit)
+	  echo $body | grep -q "Signed-off-by:" \
+	      || echo "\tCommit" $commit "(Signed-off-by:)"
+      done)
+[ -z "$bad" ] || { printf "Missing obligatory tag: \n$bad\n"\
+	&& failure=true;}
+
 total=$(echo "$commits" | wc -l)
 if $failure ; then
 	printf "\nInvalid patch(es) found - checked $total patch"
diff --git a/doc/guides/contributing/patches.rst b/doc/guides/contributing/patches.rst
index bebcaf3925..868a9a7bf2 100644
--- a/doc/guides/contributing/patches.rst
+++ b/doc/guides/contributing/patches.rst
@@ -360,6 +360,31 @@ Where ``NNNNN`` is patchwork ID for patch or series::
      ---
      Depends-on: series-10000 ("Title of the series")
 
+Tag order
+~~~~~~~~~
+
+There is a pattern indicating how tags should relate to each other.
+
+Example of proper tag sequence::
+
+     Coverity issue:
+     Bugzilla ID:
+     Fixes:
+     Cc:
+
+     Suggested-by:
+     Reported-by:
+     Signed-off-by:
+     Acked-by:
+     Reviewed-by:
+     Tested-by:
+
+Between first and second tag section there is and empty line.
+
+While ``Signed-off-by:`` is an obligatory tag and must exists in each commit,
+all other tags are optional. Any tag, as long as it is in proper location
+to other adjacent tags (if present), may occur multiple times.
+
 Creating Patches
 ----------------
 
-- 
2.25.1