blob: 3f597c37bab3d370ae1565f9148f192834dfbf15 [file] [log] [blame]
Sean Paul592c98a2018-09-04 15:30:29 -04001#! /usr/bin/env bash
2
Roman Stratiienko32957192022-12-15 10:12:31 +02003check_tool_installed() {
4 if ! command -v $1 &> /dev/null
5 then
6 echo "Please install '$1' tool"
7 exit 1
8 fi
9}
10
Sean Paul68a78ef2018-09-04 15:32:26 -040011echoerr() {
12 printf "ERROR: %s\n" "$*" >&2
13}
14
Sean Pauldafaabd2019-01-30 09:45:21 -050015findtag() {
16 local commit_body tag person
17 commit_body=$1
18 tag=$2
19 person=$3
20
21 # trim duplicate spaces from commit body and person
22 match="$tag: $(echo $person | tr -s ' ')"
23
24 if [ -z "$(echo "$commit_body" | tr -s ' ' | grep -i "$match")" ]; then
25 echoerr "Tag is missing from commit body"
26 echoerr ""
27 echoerr "Looking for '"$match"' in: "
28 echoerr "-----------------------------------------------------"
29 echoerr "$commit_body"
30 echoerr "-----------------------------------------------------"
31 echoerr ""
32 return 0
33 fi
34
35 return 1
36}
37
Roman Stratiienko32957192022-12-15 10:12:31 +020038check_tool_installed bpfmt
Roman Stratiienko57ba08a2024-10-17 01:48:10 +030039check_tool_installed clang-format-diff-19
Roman Stratiienko32957192022-12-15 10:12:31 +020040
Sean Paul592c98a2018-09-04 15:30:29 -040041git fetch https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer.git
42
Sean Paul68a78ef2018-09-04 15:32:26 -040043git log --pretty='%h' FETCH_HEAD..HEAD | while read h; do
44 subject=$(git show -s --pretty='%s' "$h")
John Stultzf4563dc2024-10-28 16:01:37 -070045 if [[ $subject != drm_hwcomposer:* ]] && [[ $subject != Revert* ]]; then
Sean Paul68a78ef2018-09-04 15:32:26 -040046 echoerr "Invalid subject prefix: $subject"
47 exit 1
48 fi
49
50 commit_body=$(git show -s --pretty=%b "$h")
51
Sean Paul890988f2019-03-15 15:18:46 -040052 author=$(git show -s --format='%an <%ae>' "$h")
Sean Pauldafaabd2019-01-30 09:45:21 -050053 if findtag "$commit_body" "Signed-off-by" "$author"; then
Sean Paul68a78ef2018-09-04 15:32:26 -040054 echoerr "Author SoB tag is missing from commit $h"
55 exit 1
56 fi
57
Sean Paul890988f2019-03-15 15:18:46 -040058 committer=$(git show -s --format='%cn <%ce>' "$h")
Sean Pauldafaabd2019-01-30 09:45:21 -050059 if findtag "$commit_body" "Signed-off-by" "$committer"; then
Sean Paul68a78ef2018-09-04 15:32:26 -040060 echoerr "Committer SoB tag is missing from commit $h"
61 exit 1
62 fi
63
Roman Stratiienko57ba08a2024-10-17 01:48:10 +030064 git show "$h" -- | clang-format-diff-19 -p 1 -style=file > /tmp/format-fixup.patch
Roman Stratiienkod518a052021-02-25 19:15:14 +020065 if [ -s /tmp/format-fixup.patch ]; then
66 cat /tmp/format-fixup.patch >&2
Sean Paul68a78ef2018-09-04 15:32:26 -040067 exit 1
68 fi
Roman Stratiienkod6659982021-02-27 22:08:51 +020069
70 find -name "*.bp" -exec bpfmt -d -s {} \; > /tmp/bpfmt.patch
71 if [ -s /tmp/bpfmt.patch ]; then
72 cat /tmp/bpfmt.patch >&2
73 exit 1
74 fi
Sean Paul68a78ef2018-09-04 15:32:26 -040075done