summaryrefslogtreecommitdiffstats
path: root/scripts/hooks/sendemail-validate.signoffby-missing-warn.sh
blob: 386571e22d96e34d155c63b1871d1a5af1df841c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash

#
# The following snippet can be used to _WARN_ if a Signed-off-by line is missing
# in the commit message of the patch
#
# Use
#
#   git config sendemail.validate true
#
# and link this script to your git hooks folder to enable.
#

GREEN='\e[0;32m'        # Green
RED='\e[0;31m' # Red
NORMAL='\e[0m' # Text Reset

GREPLINE="^Signed-off-by: $(git config user.name) <$(git config user.email)>"

if [ "$(grep -c "$GREPLINE" "$1")" -lt 1 ]; then
    echo -e >&2 "${RED}Missing Signed-off-by line.${NORMAL}\n"

    # To not only warn, but abort the patch sending, uncomment the next line
    # exit 1
else
    echo -e >&2 "${GREEN}Signed-off-by line found.${NORMAL}\n"
fi