a1261bd0b3
Bang on sed until a better incantation appears. Change-Id: Ib8ad0996b6325db0fe983c86dd7dc553c9d388c4 Type: fix Fixes: 26ce6ca1fe6f524a9049444fe8d55042fd7530a6 Signed-off-by: Jon Loeliger <jdl@netgate.com> (cherry picked from commit 171577e129363aec30640a50f91cf0ff46d61bb9)
51 lines
1.6 KiB
Bash
Executable File
51 lines
1.6 KiB
Bash
Executable File
#/bin/env bash
|
|
|
|
KNOWN_FEATURES=$(cat MAINTAINERS | sed -ne 's/^I:[[:space:]]*//p')
|
|
FEATURES=$(git show -s --format=%s --no-color \
|
|
| sed -ne 's/^\([a-z0-9 -]*\):.*$/\1/p')
|
|
KNOWN_TYPES="feature fix refactor style docs test make"
|
|
TYPE=$(git show -s --format=%b --no-color | sed -ne 's/^Type:[[:space:]]*//p')
|
|
ERR="=============================== ERROR ==============================="
|
|
|
|
# Chech that subject line contains at least one feature id
|
|
if [ $(echo ${FEATURES} | wc -w) -eq 0 ]; then
|
|
echo $ERR
|
|
echo "git commit 'Subject:' line must contain at least one known feature id."
|
|
echo "feature id(s) must be listed before ':' and space delimited "
|
|
echo "if more then one is listed."
|
|
echo "Please refer to the MAINTAINERS file (I: lines) for known feature ids."
|
|
echo $ERR
|
|
exit 1
|
|
fi
|
|
|
|
# Check that feature ids in subject line are known
|
|
for i in ${FEATURES}; do
|
|
is_known=false
|
|
for j in ${KNOWN_FEATURES}; do
|
|
[ "${i}" = "${j}" ] && is_known=true
|
|
done
|
|
if [ ${is_known} = "false" ] ; then
|
|
echo $ERR
|
|
echo "Unknown feature '${i}' in commit 'Subject:' line."
|
|
echo "Feature must exist in MAINTAINERS file. If this commit introduces "
|
|
echo "a new feature, then this commit must add an entry to the "
|
|
echo "MAINTAINERS file."
|
|
echo $ERR
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
# Check that Message body contains valid Type: entry
|
|
is_known=false
|
|
for i in ${KNOWN_TYPES}; do
|
|
[ "${i}" = "${TYPE}" ] && is_known=true
|
|
done
|
|
if [ ${is_known} = "false" ] ; then
|
|
echo $ERR
|
|
echo "Unknown commit type '${TYPE}' in commit message body."
|
|
echo "Commit message must contain known 'Type:' entry."
|
|
echo "Known types are: ${KNOWN_TYPES}"
|
|
echo $ERR
|
|
exit 1
|
|
fi
|