diff options
author | Thomas Haller <thaller@redhat.com> | 2018-10-22 12:21:46 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-10-22 13:19:15 +0200 |
commit | 369446eae69484010a05f61bfccd4dc6b38644ac (patch) | |
tree | 23f401f5b7c8893dfc54ff751368a0ac3b022863 | |
parent | a487d34fc4b4636496045c0f83306b37f01ec89b (diff) | |
download | NetworkManager-369446eae69484010a05f61bfccd4dc6b38644ac.tar.gz |
checkpatch: add "contrib/scripts/checkpatch-feature-branch.sh" script
This takes current HEAD branch, and finds all the commits what
are not on master or one of the nm-1-* branches, and runs
checkpatch.pl on each.
The use is to run checkpatch.pl on all patches of a feature
branch.
-rwxr-xr-x | contrib/scripts/checkpatch-feature-branch.sh | 31 | ||||
-rwxr-xr-x | contrib/scripts/checkpatch.pl | 8 |
2 files changed, 39 insertions, 0 deletions
diff --git a/contrib/scripts/checkpatch-feature-branch.sh b/contrib/scripts/checkpatch-feature-branch.sh new file mode 100755 index 0000000000..6741317be2 --- /dev/null +++ b/contrib/scripts/checkpatch-feature-branch.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +die() { + printf "%s\n" "$@" + exit 1 +} + +HEAD="${1:-HEAD}" + +BASE_DIR="$(dirname "$0")" + +BASE_REF="refs/remotes/origin/" + +RANGES=( $(git show-ref | sed 's#^\(.*\) '"$BASE_REF"'\(master\|nm-1-[0-9]\+\)$#\1..'"$HEAD"'#p' -n) ) + +[ "${#RANGES[@]}" != 0 ] || die "cannot detect git-ranges (HEAD is $(git rev-parse HEAD))" + +REFS=( $(git log --reverse --format='%H' "${RANGES[@]}") ) + +[ "${#REFS[@]}" != 0 ] || die "no refs detected (HEAD is $(git rev-parse HEAD))" + +SUCCESS=0 +for H in ${REFS[@]}; do + export NM_CHECKPATCH_HEADER=$'\n'">>> VALIDATE \"$(git log --oneline -n1 "$H")\"" + git format-patch -U65535 --stdout -1 "$H" | "$BASE_DIR/checkpatch.pl" + if [ $? != 0 ]; then + SUCCESS=1 + fi +done + +exit $SUCCESS diff --git a/contrib/scripts/checkpatch.pl b/contrib/scripts/checkpatch.pl index 0769273bcb..67ffbc4256 100755 --- a/contrib/scripts/checkpatch.pl +++ b/contrib/scripts/checkpatch.pl @@ -72,11 +72,19 @@ sub new_file @functions_seen = (); } +my $header = $ENV{'NM_CHECKPATCH_HEADER'}; + sub complain { my $message = shift; return unless $check_line; + + if (defined($header)) { + warn "$header\n"; + undef $header; + } + warn "$filename:$line_no: $message:\n"; warn "> $line\n\n"; $seen_error = 1; |