diff options
author | Ryan Moeller <[email protected]> | 2020-10-20 11:35:53 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2020-10-30 15:57:03 -0700 |
commit | 0905a4fe9b75ceb2bb1af25418499e95abf2c4f9 (patch) | |
tree | 0d42957d2c094fc15c1b3dfabd844bf3a70198ac | |
parent | 3ba6774e583f3ceefe29c40731d5136240d8ee08 (diff) |
Fix commitcheck on FreeBSD
Convert from bash to sh, avoid Perl regexes and \s, prune unused
functions.
Reviewed-by: Mateusz Piotrowski <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #11070
-rw-r--r-- | Makefile.am | 2 | ||||
-rwxr-xr-x | scripts/commitcheck.sh | 54 |
2 files changed, 11 insertions, 45 deletions
diff --git a/Makefile.am b/Makefile.am index b409d2196..4aaa0ad56 100644 --- a/Makefile.am +++ b/Makefile.am @@ -154,7 +154,7 @@ checkbashisms: -o -name 'make_gitrev.sh' -prune \ -o -type f ! -name 'config*' \ ! -name 'libtool' \ - -exec bash -c 'awk "NR==1 && /\#\!.*bin\/sh.*/ {print FILENAME;}" "{}"' \;); \ + -exec sh -c 'awk "NR==1 && /\#\!.*bin\/sh.*/ {print FILENAME;}" "{}"' \;); \ else \ echo "skipping checkbashisms because checkbashisms is not installed"; \ fi diff --git a/scripts/commitcheck.sh b/scripts/commitcheck.sh index 1fe29da9b..71cf52166 100755 --- a/scripts/commitcheck.sh +++ b/scripts/commitcheck.sh @@ -1,23 +1,10 @@ -#!/usr/bin/env bash +#!/bin/sh REF="HEAD" -# test a url -function test_url() -{ - url="$1" - if ! curl --output /dev/null --max-time 60 \ - --silent --head --fail "$url" ; then - echo "\"$url\" is unreachable" - return 1 - fi - - return 0 -} - # test commit body for length # lines containing urls are exempt for the length limit. -function test_commit_bodylength() +test_commit_bodylength() { length="72" body=$(git log -n 1 --pretty=%b "$REF" | grep -Ev "http(s)*://" | grep -E -m 1 ".{$((length + 1))}") @@ -30,9 +17,9 @@ function test_commit_bodylength() } # check for a tagged line -function check_tagged_line() +check_tagged_line() { - regex='^\s*'"$1"':\s[[:print:]]+\s<[[:graph:]]+>$' + regex='^[[:space:]]*'"$1"':[[:space:]][[:print:]]+[[:space:]]<[[:graph:]]+>$' foundline=$(git log -n 1 "$REF" | grep -E -m 1 "$regex") if [ -z "$foundline" ]; then echo "error: missing \"$1\"" @@ -42,30 +29,8 @@ function check_tagged_line() return 0 } -# check for a tagged line and check that the link is valid -function check_tagged_line_with_url() -{ - regex='^\s*'"$1"':\s\K([[:graph:]]+)$' - foundline=$(git log -n 1 "$REF" | grep -Po "$regex") - if [ -z "$foundline" ]; then - echo "error: missing \"$1\"" - return 1 - fi - - OLDIFS=$IFS - IFS=$'\n' - for url in $(echo -e "$foundline"); do - if ! test_url "$url"; then - return 1 - fi - done - IFS=$OLDIFS - - return 0 -} - # check commit message for a normal commit -function new_change_commit() +new_change_commit() { error=0 @@ -89,7 +54,7 @@ function new_change_commit() return $error } -function is_coverity_fix() +is_coverity_fix() { # subject starts with Fix coverity defects means it's a coverity fix subject=$(git log -n 1 --pretty=%s "$REF" | grep -E -m 1 '^Fix coverity defects') @@ -100,7 +65,7 @@ function is_coverity_fix() return 1 } -function coverity_fix_commit() +coverity_fix_commit() { error=0 @@ -119,11 +84,12 @@ function coverity_fix_commit() # test each summary line for the proper format OLDIFS=$IFS - IFS=$'\n' + IFS=' +' for line in $(git log -n 1 --pretty=%b "$REF" | grep -E '^CID'); do echo "$line" | grep -E '^CID [[:digit:]]+: ([[:graph:]]+|[[:space:]])+ \(([[:upper:]]|\_)+\)' > /dev/null # shellcheck disable=SC2181 - if [[ $? -ne 0 ]]; then + if [ $? -ne 0 ]; then echo "error: commit message has an improperly formatted CID defect line" error=1 fi |