forked from BlissRoms-x86/drm_hwcomposer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci-checkcommit.sh
executable file
·58 lines (47 loc) · 1.43 KB
/
.gitlab-ci-checkcommit.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /usr/bin/env bash
echoerr() {
printf "ERROR: %s\n" "$*" >&2
}
findtag() {
local commit_body tag person
commit_body=$1
tag=$2
person=$3
# trim duplicate spaces from commit body and person
match="$tag: $(echo $person | tr -s ' ')"
if [ -z "$(echo "$commit_body" | tr -s ' ' | grep -i "$match")" ]; then
echoerr "Tag is missing from commit body"
echoerr ""
echoerr "Looking for '"$match"' in: "
echoerr "-----------------------------------------------------"
echoerr "$commit_body"
echoerr "-----------------------------------------------------"
echoerr ""
return 0
fi
return 1
}
git fetch https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer.git
git log --pretty='%h' FETCH_HEAD..HEAD | while read h; do
subject=$(git show -s --pretty='%s' "$h")
if [[ $subject != drm_hwcomposer:* ]]; then
echoerr "Invalid subject prefix: $subject"
exit 1
fi
commit_body=$(git show -s --pretty=%b "$h")
author=$(git show -s --format='%an <%ae>' "$h")
if findtag "$commit_body" "Signed-off-by" "$author"; then
echoerr "Author SoB tag is missing from commit $h"
exit 1
fi
committer=$(git show -s --format='%cn <%ce>' "$h")
if findtag "$commit_body" "Signed-off-by" "$committer"; then
echoerr "Committer SoB tag is missing from commit $h"
exit 1
fi
git show "$h" -- | clang-format-diff-5.0 -p 1 -style=file > format-fixup.patch
if [ -s format-fixup.patch ]; then
cat format-fixup.patch >&2
exit 1
fi
done