blob: c1c524d661fe9b3d95d84a45d417bc45d3fe930c [file] [log] [blame]
Sean Paul592c98a2018-09-04 15:30:29 -04001#! /usr/bin/env bash
2
Sean Paul68a78ef2018-09-04 15:32:26 -04003echoerr() {
4 printf "ERROR: %s\n" "$*" >&2
5}
6
Sean Pauldafaabd2019-01-30 09:45:21 -05007findtag() {
8 local commit_body tag person
9 commit_body=$1
10 tag=$2
11 person=$3
12
13 # trim duplicate spaces from commit body and person
14 match="$tag: $(echo $person | tr -s ' ')"
15
16 if [ -z "$(echo "$commit_body" | tr -s ' ' | grep -i "$match")" ]; then
17 echoerr "Tag is missing from commit body"
18 echoerr ""
19 echoerr "Looking for '"$match"' in: "
20 echoerr "-----------------------------------------------------"
21 echoerr "$commit_body"
22 echoerr "-----------------------------------------------------"
23 echoerr ""
24 return 0
25 fi
26
27 return 1
28}
29
Sean Paul592c98a2018-09-04 15:30:29 -040030git fetch https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer.git
31
Sean Paul68a78ef2018-09-04 15:32:26 -040032git log --pretty='%h' FETCH_HEAD..HEAD | while read h; do
33 subject=$(git show -s --pretty='%s' "$h")
34 if [[ $subject != drm_hwcomposer:* ]]; then
35 echoerr "Invalid subject prefix: $subject"
36 exit 1
37 fi
38
39 commit_body=$(git show -s --pretty=%b "$h")
40
Sean Paul890988f2019-03-15 15:18:46 -040041 author=$(git show -s --format='%an <%ae>' "$h")
Sean Pauldafaabd2019-01-30 09:45:21 -050042 if findtag "$commit_body" "Signed-off-by" "$author"; then
Sean Paul68a78ef2018-09-04 15:32:26 -040043 echoerr "Author SoB tag is missing from commit $h"
44 exit 1
45 fi
46
Sean Paul890988f2019-03-15 15:18:46 -040047 committer=$(git show -s --format='%cn <%ce>' "$h")
Sean Pauldafaabd2019-01-30 09:45:21 -050048 if findtag "$commit_body" "Signed-off-by" "$committer"; then
Sean Paul68a78ef2018-09-04 15:32:26 -040049 echoerr "Committer SoB tag is missing from commit $h"
50 exit 1
51 fi
52
53 git show "$h" -- | clang-format-diff-5.0 -p 1 -style=file > format-fixup.patch
54 if [ -s format-fixup.patch ]; then
55 cat format-fixup.patch >&2
56 exit 1
57 fi
58done