mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 06:08:02 +02:00
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.
This commit is contained in:
parent
a487d34fc4
commit
369446eae6
2 changed files with 39 additions and 0 deletions
31
contrib/scripts/checkpatch-feature-branch.sh
Executable file
31
contrib/scripts/checkpatch-feature-branch.sh
Executable file
|
|
@ -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
|
||||||
|
|
@ -72,11 +72,19 @@ sub new_file
|
||||||
@functions_seen = ();
|
@functions_seen = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $header = $ENV{'NM_CHECKPATCH_HEADER'};
|
||||||
|
|
||||||
sub complain
|
sub complain
|
||||||
{
|
{
|
||||||
my $message = shift;
|
my $message = shift;
|
||||||
|
|
||||||
return unless $check_line;
|
return unless $check_line;
|
||||||
|
|
||||||
|
if (defined($header)) {
|
||||||
|
warn "$header\n";
|
||||||
|
undef $header;
|
||||||
|
}
|
||||||
|
|
||||||
warn "$filename:$line_no: $message:\n";
|
warn "$filename:$line_no: $message:\n";
|
||||||
warn "> $line\n\n";
|
warn "> $line\n\n";
|
||||||
$seen_error = 1;
|
$seen_error = 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue