5 # test commit body for length
6 # lines containing urls are exempt for the length limit.
7 test_commit_bodylength()
10 body=$(git log -n 1 --pretty=%b "$REF" | grep -Ev "http(s)*://" | grep -E -m 1 ".{$((length + 1))}")
11 if [ -n "$body" ]; then
12 echo "error: commit message body contains line over ${length} characters"
19 # check for a tagged line
22 regex='^[[:space:]]*'"$1"':[[:space:]][[:print:]]+[[:space:]]<[[:graph:]]+>$'
23 foundline=$(git log -n 1 "$REF" | grep -E -m 1 "$regex")
24 if [ -z "$foundline" ]; then
25 echo "error: missing \"$1\""
32 # check commit message for a normal commit
37 # subject is not longer than 72 characters
38 long_subject=$(git log -n 1 --pretty=%s "$REF" | grep -E -m 1 '.{73}')
39 if [ -n "$long_subject" ]; then
40 echo "error: commit subject over 72 characters"
44 # need a signed off by
45 if ! check_tagged_line "Signed-off-by" ; then
49 # ensure that no lines in the body of the commit are over 72 characters
50 if ! test_commit_bodylength ; then
59 # subject starts with Fix coverity defects means it's a coverity fix
60 subject=$(git log -n 1 --pretty=%s "$REF" | grep -E -m 1 '^Fix coverity defects')
61 if [ -n "$subject" ]; then
72 # subject starts with Fix coverity defects: CID dddd, dddd...
73 subject=$(git log -n 1 --pretty=%s "$REF" |
74 grep -E -m 1 'Fix coverity defects: CID [[:digit:]]+(, [[:digit:]]+)*')
75 if [ -z "$subject" ]; then
76 echo "error: Coverity defect fixes must have a subject line that starts with \"Fix coverity defects: CID dddd\""
80 # need a signed off by
81 if ! check_tagged_line "Signed-off-by" ; then
85 # test each summary line for the proper format
89 for line in $(git log -n 1 --pretty=%b "$REF" | grep -E '^CID'); do
90 if ! echo "$line" | grep -qE '^CID [[:digit:]]+: ([[:graph:]]+|[[:space:]])+ \(([[:upper:]]|\_)+\)'; then
91 echo "error: commit message has an improperly formatted CID defect line"
97 # ensure that no lines in the body of the commit are over 72 characters
98 if ! test_commit_bodylength; then
109 # if coverity fix, test against that
110 if is_coverity_fix; then
111 if ! coverity_fix_commit; then
118 # have a normal commit
119 if ! new_change_commit ; then