~matthiasbeyer/imag

ref: 9b48dc27cd00fcc75917c2702dc8dc4c6493e8d3 imag/scripts/hooks/applypatch-msg.check-signed-off.sh -rw-r--r-- 789 bytes
9b48dc27Matthias Beyer libimagentryref: Move from error-chain to failure 3 years ago
                                                                                
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
29
30
31
32
33
#!/usr/bin/env bash
#
# An hook script to check the commit log message taken by
# applypatch from an e-mail message for proper "Signed-off-by" line(s).
#
# To enable this hook, copy this file to ".git/hooks/applypatch-msg" and make it
# executable.

#
# This hook is used when applying patches which are send via mail, to verify the
# Signed-off-by line is in the commit message.
#

. git-sh-setup

RED='\e[0;31m'      # Red
YELLOW='\e[0;33m'   # Yellow
NORMAL='\e[0m'      # Text Reset

warn() {
    echo -e >&2 "${YELLOW}$*${DEFAULT}"
}

abort() {
    echo -e >&2 "${RED}$*${DEFAULT}"
    exit 1
}

headline=$(head -n 1 $1 | wc -c)
[[ $headline -gt 50 ]] && warn "Headline of patch longer than 50 chars"

grep "^Signed-off-by" $1 >/dev/null 2>/dev/null && abort "No Signed-off-by line"