3 KNOWN_FEATURES=$(cat MAINTAINERS | sed -ne 's/^I:[[:space:]]*//p')
4 FEATURES=$(git show -s --format=%s --no-color \
5 | sed -ne 's/^\([a-z0-9 -]*\):.*$/\1/p')
6 KNOWN_TYPES="feature fix refactor improvement style docs test make"
7 TYPE=$(git show -s --format=%b --no-color | sed -ne 's/^Type:[[:space:]]*//p')
8 ERR="=============================== ERROR ==============================="
10 # Chech that subject line contains at least one feature id
11 if [ $(echo ${FEATURES} | wc -w) -eq 0 ]; then
13 echo "git commit 'Subject:' line must contain at least one known feature id."
14 echo "feature id(s) must be listed before ':' and space delimited "
15 echo "if more then one is listed."
16 echo "Please refer to the MAINTAINERS file (I: lines) for known feature ids."
21 # Check that feature ids in subject line are known
22 for i in ${FEATURES}; do
24 for j in ${KNOWN_FEATURES}; do
25 [ "${i}" = "${j}" ] && is_known=true
27 if [ ${is_known} = "false" ] ; then
29 echo "Unknown feature '${i}' in commit 'Subject:' line."
30 echo "Feature must exist in MAINTAINERS file. If this commit introduces "
31 echo "a new feature, then this commit must add an entry to the "
32 echo "MAINTAINERS file."
38 # Check that Message body contains valid Type: entry
40 for i in ${KNOWN_TYPES}; do
41 [ "${i}" = "${TYPE}" ] && is_known=true
43 if [ ${is_known} = "false" ] ; then
45 echo "Unknown commit type '${TYPE}' in commit message body."
46 echo "Commit message must contain known 'Type:' entry."
47 echo "Known types are: ${KNOWN_TYPES}"
51 echo "*******************************************************************"
52 echo "* VPP Commit Message Checkstyle Successfully Completed"
53 echo "*******************************************************************"