Sean Paul | 592c98a | 2018-09-04 15:30:29 -0400 | [diff] [blame] | 1 | #! /usr/bin/env bash |
| 2 | |
Roman Stratiienko | 3295719 | 2022-12-15 10:12:31 +0200 | [diff] [blame] | 3 | check_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 Paul | 68a78ef | 2018-09-04 15:32:26 -0400 | [diff] [blame] | 11 | echoerr() { |
| 12 | printf "ERROR: %s\n" "$*" >&2 |
| 13 | } |
| 14 | |
Sean Paul | dafaabd | 2019-01-30 09:45:21 -0500 | [diff] [blame] | 15 | findtag() { |
| 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 Stratiienko | 3295719 | 2022-12-15 10:12:31 +0200 | [diff] [blame] | 38 | check_tool_installed bpfmt |
Roman Stratiienko | 57ba08a | 2024-10-17 01:48:10 +0300 | [diff] [blame] | 39 | check_tool_installed clang-format-diff-19 |
Roman Stratiienko | 3295719 | 2022-12-15 10:12:31 +0200 | [diff] [blame] | 40 | |
Sean Paul | 592c98a | 2018-09-04 15:30:29 -0400 | [diff] [blame] | 41 | git fetch https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer.git |
| 42 | |
Sean Paul | 68a78ef | 2018-09-04 15:32:26 -0400 | [diff] [blame] | 43 | git log --pretty='%h' FETCH_HEAD..HEAD | while read h; do |
| 44 | subject=$(git show -s --pretty='%s' "$h") |
John Stultz | f4563dc | 2024-10-28 16:01:37 -0700 | [diff] [blame] | 45 | if [[ $subject != drm_hwcomposer:* ]] && [[ $subject != Revert* ]]; then |
Sean Paul | 68a78ef | 2018-09-04 15:32:26 -0400 | [diff] [blame] | 46 | echoerr "Invalid subject prefix: $subject" |
| 47 | exit 1 |
| 48 | fi |
| 49 | |
| 50 | commit_body=$(git show -s --pretty=%b "$h") |
| 51 | |
Sean Paul | 890988f | 2019-03-15 15:18:46 -0400 | [diff] [blame] | 52 | author=$(git show -s --format='%an <%ae>' "$h") |
Sean Paul | dafaabd | 2019-01-30 09:45:21 -0500 | [diff] [blame] | 53 | if findtag "$commit_body" "Signed-off-by" "$author"; then |
Sean Paul | 68a78ef | 2018-09-04 15:32:26 -0400 | [diff] [blame] | 54 | echoerr "Author SoB tag is missing from commit $h" |
| 55 | exit 1 |
| 56 | fi |
| 57 | |
Sean Paul | 890988f | 2019-03-15 15:18:46 -0400 | [diff] [blame] | 58 | committer=$(git show -s --format='%cn <%ce>' "$h") |
Sean Paul | dafaabd | 2019-01-30 09:45:21 -0500 | [diff] [blame] | 59 | if findtag "$commit_body" "Signed-off-by" "$committer"; then |
Sean Paul | 68a78ef | 2018-09-04 15:32:26 -0400 | [diff] [blame] | 60 | echoerr "Committer SoB tag is missing from commit $h" |
| 61 | exit 1 |
| 62 | fi |
| 63 | |
Roman Stratiienko | 57ba08a | 2024-10-17 01:48:10 +0300 | [diff] [blame] | 64 | git show "$h" -- | clang-format-diff-19 -p 1 -style=file > /tmp/format-fixup.patch |
Roman Stratiienko | d518a05 | 2021-02-25 19:15:14 +0200 | [diff] [blame] | 65 | if [ -s /tmp/format-fixup.patch ]; then |
| 66 | cat /tmp/format-fixup.patch >&2 |
Sean Paul | 68a78ef | 2018-09-04 15:32:26 -0400 | [diff] [blame] | 67 | exit 1 |
| 68 | fi |
Roman Stratiienko | d665998 | 2021-02-27 22:08:51 +0200 | [diff] [blame] | 69 | |
| 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 Paul | 68a78ef | 2018-09-04 15:32:26 -0400 | [diff] [blame] | 75 | done |