scripts: check headline of drivers commits
authorNelio Laranjeiro <nelio.laranjeiro@6wind.com>
Wed, 29 Jun 2016 15:55:08 +0000 (17:55 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Sun, 10 Jul 2016 14:34:11 +0000 (16:34 +0200)
A driver patch under net should start with "net/<driver name>" or if
a patch touch multiple drivers, it should only start with "net:".
The same apply for crypto.
A patch touching all drivers (net + crypto) should start with "drivers:".

Longer prefixes like "net/mlx:" (for mlx4/mlx5) or "net/e1000/base:" are
handled by not checking the colon.

The directories doc/ and config/ are ignored because a driver patch
can modify them.

Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
scripts/check-git-log.sh

index 035acf6..8a7ddbd 100755 (executable)
@@ -70,6 +70,24 @@ bad=$(echo "$headlines" | grep --color=always \
        | sed 's,^,\t,')
 [ -z "$bad" ] || printf "Wrong headline format:\n$bad\n"
 
+# check headline prefix when touching only drivers, e.g. net/<driver name>
+bad=$(for commit in $commits ; do
+       headline=$(git log --format='%s' -1 $commit)
+       files=$(git diff-tree --no-commit-id --name-only -r $commit)
+       [ -z "$(echo "$files" | grep -v '^\(drivers\|doc\|config\)/')" ] ||
+               continue
+       drv=$(echo "$files" | grep '^drivers/' | cut -d "/" -f 2,3 | sort -u)
+       drvgrp=$(echo "$drv" | cut -d "/" -f 1 | uniq)
+       if [ $(echo "$drvgrp" | wc -l) -gt 1 ] ; then
+               echo "$headline" | grep -v '^drivers:'
+       elif [ $(echo "$drv" | wc -l) -gt 1 ] ; then
+               echo "$headline" | grep -v "^$drvgrp"
+       else
+               echo "$headline" | grep -v "^$drv"
+       fi
+done | sed 's,^,\t,')
+[ -z "$bad" ] || printf "Wrong headline prefix:\n$bad\n"
+
 # check headline label for common typos
 bad=$(echo "$headlines" | grep --color=always \
        -e '^example[:/]' \