DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] devtools: return error on failure
Date: Tue, 25 Jun 2019 18:01:06 +0100	[thread overview]
Message-ID: <20190625170107.87583-1-ferruh.yigit@intel.com> (raw)

Currently script is always returning success, returning failure on error
helps on using script on automation tools.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 devtools/check-git-log.sh | 56 ++++++++++++++++++++++++++++++---------
 1 file changed, 43 insertions(+), 13 deletions(-)

diff --git a/devtools/check-git-log.sh b/devtools/check-git-log.sh
index a763ccf78..509d8ef1d 100755
--- a/devtools/check-git-log.sh
+++ b/devtools/check-git-log.sh
@@ -19,6 +19,8 @@ if [ "$1" = '-h' -o "$1" = '--help' ] ; then
 	exit
 fi
 
+ret=0
+
 selfdir=$(dirname $(readlink -f $0))
 range=${1:-origin/master..}
 # convert -N to HEAD~N.. in order to comply with git-log-fixes.sh getopts
@@ -46,7 +48,9 @@ bad=$(echo "$headlines" | grep --color=always \
 	-e ':[^ ]' \
 	-e ' :' \
 	| sed 's,^,\t,')
-[ -z "$bad" ] || printf "Wrong headline format:\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Wrong headline format:\n$bad\n" && ret=$((ret+1))
+fi
 
 # check headline prefix when touching only drivers, e.g. net/<driver name>
 bad=$(for commit in $commits ; do
@@ -64,7 +68,9 @@ bad=$(for commit in $commits ; do
 		echo "$headline" | grep -v "^$drv"
 	fi
 done | sed 's,^,\t,')
-[ -z "$bad" ] || printf "Wrong headline prefix:\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Wrong headline prefix:\n$bad\n" && ret=$((ret+1))
+fi
 
 # check headline label for common typos
 bad=$(echo "$headlines" | grep --color=always \
@@ -74,14 +80,18 @@ bad=$(echo "$headlines" | grep --color=always \
 	-e 'test-pmd' \
 	-e '^bond:' \
 	| sed 's,^,\t,')
-[ -z "$bad" ] || printf "Wrong headline label:\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Wrong headline label:\n$bad\n" && ret=$((ret+1))
+fi
 
 # check headline lowercase for first words
 bad=$(echo "$headlines" | grep --color=always \
 	-e '^.*[[:upper:]].*:' \
 	-e ': *[[:upper:]]' \
 	| sed 's,^,\t,')
-[ -z "$bad" ] || printf "Wrong headline uppercase:\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Wrong headline uppercase:\n$bad\n" && ret=$((ret+1))
+fi
 
 # check headline uppercase (Rx/Tx, VF, L2, MAC, Linux, ARM...)
 bad=$(echo "$headlines" | grep -E --color=always \
@@ -127,46 +137,60 @@ bad=$(echo "$headlines" | grep -E --color=always \
 	| grep \
 	-v ':.*\<OCTEON\ TX\>' \
 	| sed 's,^,\t,')
-[ -z "$bad" ] || printf "Wrong headline lowercase:\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Wrong headline lowercase:\n$bad\n" && ret=$((ret+1))
+fi
 
 # special case check for VMDq to give good error message
 bad=$(echo "$headlines" | grep -E --color=always \
 	-e '\<(vmdq|VMDQ)\>' \
 	| sed 's,^,\t,')
-[ -z "$bad" ] || printf "Wrong headline capitalization, use 'VMDq':\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Wrong headline capitalization, use 'VMDq':\n$bad\n" && ret=$((ret+1))
+fi
 
 # check headline length (60 max)
 bad=$(echo "$headlines" |
 	awk 'length>60 {print}' |
 	sed 's,^,\t,')
-[ -z "$bad" ] || printf "Headline too long:\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Headline too long:\n$bad\n" && ret=$((ret+1))
+fi
 
 # check body lines length (75 max)
 bad=$(echo "$bodylines" | grep -v '^Fixes:' |
 	awk 'length>75 {print}' |
 	sed 's,^,\t,')
-[ -z "$bad" ] || printf "Line too long:\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Line too long:\n$bad\n" && ret=$((ret+1))
+fi
 
 # check starting commit message with "It"
 bad=$(for commit in $commits ; do
 	firstbodyline=$(git log --format='%b' -1 $commit | head -n1)
 	echo "$firstbodyline" | grep --color=always -ie '^It '
 done | sed 's,^,\t,')
-[ -z "$bad" ] || printf "Wrong beginning of commit message:\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Wrong beginning of commit message:\n$bad\n" && ret=$((ret+1))
+fi
 
 # check tags spelling
 bad=$(echo "$tags" |
 	grep -v "^$bytag [^,]* <.*@.*>$" |
 	grep -v '^Fixes: [0-9a-f]\{7\}[0-9a-f]* (".*")$' |
 	sed 's,^.,\t&,')
-[ -z "$bad" ] || printf "Wrong tag:\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Wrong tag:\n$bad\n" && ret=$((ret+1))
+fi
 
 # check missing Fixes: tag
 bad=$(for fix in $fixes ; do
 	git log --format='%b' -1 $fix | grep -q '^Fixes: ' ||
 		git log --format='\t%s' -1 $fix
 done)
-[ -z "$bad" ] || printf "Missing 'Fixes' tag:\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Missing 'Fixes' tag:\n$bad\n" && ret=$((ret+1))
+fi
 
 # check Fixes: reference
 IFS='
@@ -181,11 +205,17 @@ bad=$(for fixtag in $fixtags ; do
 	fi
 	printf "$fixtag" | grep -v "^$good$"
 done | sed 's,^,\t,')
-[ -z "$bad" ] || printf "Wrong 'Fixes' reference:\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Wrong 'Fixes' reference:\n$bad\n" && ret=$((ret+1))
+fi
 
 # check Cc: stable@dpdk.org for fixes
 bad=$(for fix in $stablefixes ; do
 	git log --format='%b' -1 $fix | grep -qi '^Cc: *stable@dpdk.org' ||
 		git log --format='\t%s' -1 $fix
 done)
-[ -z "$bad" ] || printf "Is it candidate for Cc: stable@dpdk.org backport?\n$bad\n"
+if [ ! -z "$bad" ]; then
+	printf "Is it candidate for Cc: stable@dpdk.org backport?\n$bad\n" && ret=$((ret+1))
+fi
+
+exit $ret
-- 
2.21.0


             reply	other threads:[~2019-06-25 17:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-25 17:01 Ferruh Yigit [this message]
2019-06-28 16:27 ` Stephen Hemminger
2019-06-28 19:40   ` Bruce Richardson
2020-07-30 22:56 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190625170107.87583-1-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).