devtools: export title syntax for check-git-log

Message ID 20191025095957.29632-1-sean.morrissey@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series devtools: export title syntax for check-git-log |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK

Commit Message

Sean Morrissey Oct. 25, 2019, 9:59 a.m. UTC
  Moved title syntax to a separate file so that it improves code readability
and allows for easy addition of new correct title syntax in future cases.

Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>
---
 devtools/check-git-log.sh        | 60 ++++++++------------------------
 devtools/commit-title-syntax.txt | 45 ++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 45 deletions(-)
 create mode 100644 devtools/commit-title-syntax.txt
  

Comments

Ferruh Yigit Oct. 25, 2019, 1:44 p.m. UTC | #1
On 10/25/2019 10:59 AM, Sean Morrissey wrote:
> Moved title syntax to a separate file so that it improves code readability
> and allows for easy addition of new correct title syntax in future cases.
> 
> Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Thomas Monjalon Feb. 22, 2020, 8:38 p.m. UTC | #2
Hi,

Sorry for not looking at this patch before.

25/10/2019 11:59, Sean Morrissey:
> Moved title syntax to a separate file so that it improves code readability
> and allows for easy addition of new correct title syntax in future cases.

I think it is a good idea for a reason which is not said here:
the logic is switched from checking bad patterns to checking good wording.

> Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>
[...]
> +data="$selfdir/commit-title-syntax.txt"

The file is processed to check specifically the case of words,
so it should be renamed to something like words-case.txt
The file need to be added to MAINTAINERS file as well.

The variable name "data" is too vague. I suggest "words".

> +while IFS= read -r line

We should avoid "while" loop because it is a sub-shell,
so it forbids setting global variables as it is done
in another patch collecting stats:
	https://patches.dpdk.org/patch/65243/

"for" loop should be fine.

The variable name should be "word" I think.

> +do
> +	regex=":.*\<$line\>"
> +	bad=$(echo "$headlines" | grep -i $regex | grep \

If using -o option of grep, we can capture the word and compare directly
with the correct word. It will be also better when printing the error.

> +		-v ':.*\<OCTEON\ TX\>' )

I don't like having this exception but I have no better idea.
We can move it before the first grep so it will still work with grep -o.

> +	if ! [ -z "$bad" ]
> +	then
> +		bad=$(echo "$headlines" | grep --color=always -v $regex \
> +			| grep --color=always -i $regex \
> +			| sed 's,^,\t,')
> +		[ -z "$bad" ] || printf "Wrong headline case:\n$bad\n"

As said above, the word can be printed alone if using grep -o.

> +	fi
> +done < "$data"
>  
>  # special case check for VMDq to give good error message
>  bad=$(echo "$headlines" | grep -E --color=always \

The VMDq case should be moved as well.

> --- /dev/null
> +++ b/devtools/commit-title-syntax.txt
> @@ -0,0 +1,45 @@
> +Rx
> +Tx
> +PF
> +VF
> +HW
> +SW
> +FW
> +L2
> +L3
> +L4
> +API
> +arm

The right syntax is Arm.

> +aarch64

aarch32 is missing.

> +armv7
> +armv8
> +CRC
> +DCB
> +DMA
> +EEPROM
> +FreeBSD
> +IOVA
> +LACP
> +Linux
> +LRO
> +LSC
> +MAC
> +MSS
> +MTU
> +NIC
> +NVM
> +NUMA
> +PCI
> +PHY
> +PMD
> +RETA
> +RSS
> +SCTP
> +TOS
> +TPID
> +TSO
> +TTL
> +UDP
> +VLAN
> +VDPA

The right syntax is vDPA

> +VSI
  

Patch

diff --git a/devtools/check-git-log.sh b/devtools/check-git-log.sh
index a763ccf78..4152f6dfa 100755
--- a/devtools/check-git-log.sh
+++ b/devtools/check-git-log.sh
@@ -83,51 +83,21 @@  bad=$(echo "$headlines" | grep --color=always \
 	| sed 's,^,\t,')
 [ -z "$bad" ] || printf "Wrong headline uppercase:\n$bad\n"
 
-# check headline uppercase (Rx/Tx, VF, L2, MAC, Linux, ARM...)
-bad=$(echo "$headlines" | grep -E --color=always \
-	-e ':.*\<(rx|tx|RX|TX)\>' \
-	-e ':.*\<[pv]f\>' \
-	-e ':.*\<[hsf]w\>' \
-	-e ':.*\<l[234]\>' \
-	-e ':.*\<api\>' \
-	-e ':.*\<ARM\>' \
-	-e ':.*\<(Aarch64|AArch64|AARCH64|Aarch32|AArch32|AARCH32)\>' \
-	-e ':.*\<(Armv7|ARMv7|ArmV7|armV7|ARMV7)\>' \
-	-e ':.*\<(Armv8|ARMv8|ArmV8|armV8|ARMV8)\>' \
-	-e ':.*\<crc\>' \
-	-e ':.*\<dcb\>' \
-	-e ':.*\<dma\>' \
-	-e ':.*\<eeprom\>' \
-	-e ':.*\<freebsd\>' \
-	-e ':.*\<iova\>' \
-	-e ':.*\<lacp\>' \
-	-e ':.*\<linux\>' \
-	-e ':.*\<lro\>' \
-	-e ':.*\<lsc\>' \
-	-e ':.*\<mac\>' \
-	-e ':.*\<mss\>' \
-	-e ':.*\<mtu\>' \
-	-e ':.*\<nic\>' \
-	-e ':.*\<nvm\>' \
-	-e ':.*\<numa\>' \
-	-e ':.*\<pci\>' \
-	-e ':.*\<phy\>' \
-	-e ':.*\<pmd\>' \
-	-e ':.*\<reta\>' \
-	-e ':.*\<rss\>' \
-	-e ':.*\<sctp\>' \
-	-e ':.*\<tos\>' \
-	-e ':.*\<tpid\>' \
-	-e ':.*\<tso\>' \
-	-e ':.*\<ttl\>' \
-	-e ':.*\<udp\>' \
-	-e ':.*\<[Vv]lan\>' \
-	-e ':.*\<vdpa\>' \
-	-e ':.*\<vsi\>' \
-	| grep \
-	-v ':.*\<OCTEON\ TX\>' \
-	| sed 's,^,\t,')
-[ -z "$bad" ] || printf "Wrong headline lowercase:\n$bad\n"
+# check headline case (Rx/Tx, VF, L2, MAC, Linux ...)
+data="$selfdir/commit-title-syntax.txt"
+while IFS= read -r line
+do
+	regex=":.*\<$line\>"
+	bad=$(echo "$headlines" | grep -i $regex | grep \
+		-v ':.*\<OCTEON\ TX\>' )
+	if ! [ -z "$bad" ]
+	then
+		bad=$(echo "$headlines" | grep --color=always -v $regex \
+			| grep --color=always -i $regex \
+			| sed 's,^,\t,')
+		[ -z "$bad" ] || printf "Wrong headline case:\n$bad\n"
+	fi
+done < "$data"
 
 # special case check for VMDq to give good error message
 bad=$(echo "$headlines" | grep -E --color=always \
diff --git a/devtools/commit-title-syntax.txt b/devtools/commit-title-syntax.txt
new file mode 100644
index 000000000..0d4b9af01
--- /dev/null
+++ b/devtools/commit-title-syntax.txt
@@ -0,0 +1,45 @@ 
+Rx
+Tx
+PF
+VF
+HW
+SW
+FW
+L2
+L3
+L4
+API
+arm
+aarch64
+armv7
+armv8
+CRC
+DCB
+DMA
+EEPROM
+FreeBSD
+IOVA
+LACP
+Linux
+LRO
+LSC
+MAC
+MSS
+MTU
+NIC
+NVM
+NUMA
+PCI
+PHY
+PMD
+RETA
+RSS
+SCTP
+TOS
+TPID
+TSO
+TTL
+UDP
+VLAN
+VDPA
+VSI