Sean Paul | 592c98a | 2018-09-04 15:30:29 -0400 | [diff] [blame] | 1 | #! /usr/bin/env bash |
| 2 | |
Sean Paul | 68a78ef | 2018-09-04 15:32:26 -0400 | [diff] [blame] | 3 | echoerr() { |
| 4 | printf "ERROR: %s\n" "$*" >&2 |
| 5 | } |
| 6 | |
Sean Paul | dafaabd | 2019-01-30 09:45:21 -0500 | [diff] [blame] | 7 | findtag() { |
| 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 Paul | 592c98a | 2018-09-04 15:30:29 -0400 | [diff] [blame] | 30 | git fetch https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer.git |
| 31 | |
Sean Paul | 68a78ef | 2018-09-04 15:32:26 -0400 | [diff] [blame] | 32 | git 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 Paul | 890988f | 2019-03-15 15:18:46 -0400 | [diff] [blame^] | 41 | author=$(git show -s --format='%an <%ae>' "$h") |
Sean Paul | dafaabd | 2019-01-30 09:45:21 -0500 | [diff] [blame] | 42 | if findtag "$commit_body" "Signed-off-by" "$author"; then |
Sean Paul | 68a78ef | 2018-09-04 15:32:26 -0400 | [diff] [blame] | 43 | echoerr "Author SoB tag is missing from commit $h" |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
Sean Paul | 890988f | 2019-03-15 15:18:46 -0400 | [diff] [blame^] | 47 | committer=$(git show -s --format='%cn <%ce>' "$h") |
Sean Paul | dafaabd | 2019-01-30 09:45:21 -0500 | [diff] [blame] | 48 | if findtag "$commit_body" "Signed-off-by" "$committer"; then |
Sean Paul | 68a78ef | 2018-09-04 15:32:26 -0400 | [diff] [blame] | 49 | 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 |
| 58 | done |