Skip to content

Commit

Permalink
checkpatches: verify in-reply-to header when possible
Browse files Browse the repository at this point in the history
When using checkpatches.sh locally, verify that there is an In-Reply-To
header when the patch is a respin (i.e. v2, v3, etc.). This is currently
only enforced by the upstream CI but cannot be verified locally.

This cannot be verified when checking commit ids since --in-reply-to is
a git-format-patch option which is not specified by checkpatches.sh when
generating temporary files.

Here is an example:

 $ git format-patch -v6 -1 --stdout | devtools/checkpatches.sh
 warning: [PATCH v6] graph: expose node context as pointers
 warning: respins must be --in-reply-to=<v1.patch@message.id>.
 0/1 valid patch

 $ git format-patch -v6 -1 --stdout --in-reply-to=foo | \
                     devtools/checkpatches.sh
 1/1 valid patch

Link: https://git.dpdk.org/tools/dpdk-ci/commit/?id=070b31649e48460b3
Signed-off-by: Robin Jarry <rjarry@redhat.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
rjarry authored and ovsrobot committed Jul 5, 2024
1 parent fcfb19c commit d1cf753
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions devtools/checkpatches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,13 @@ status=0
check () { # <patch-file> <commit>
local ret=0
local subject=''
local check_in_reply_to=false
headline_printed=false

total=$(($total + 1))
if [ -n "$1" ] ; then
tmpinput=$1
check_in_reply_to=true
else
tmpinput=$(mktemp -t dpdk.checkpatches.XXXXXX)
trap "rm -f '$tmpinput'" INT
Expand All @@ -413,13 +415,24 @@ check () { # <patch-file> <commit>
--no-stat --stdout -1 $commit > "$tmpinput"
else
cat > "$tmpinput"
check_in_reply_to=true
fi
fi

# Subject can be on 2 lines
subject=$(sed '/^Subject: */!d;s///;N;s,\n[[:space:]]\+, ,;s,\n.*,,;q' "$tmpinput")
! $verbose || print_headline "$subject"

# check In-Reply-To for version > 1
if [ "$check_in_reply_to" = true ] \
&& echo "$subject" | grep -qi 'v[2-9].*\]' \
&& ! grep -qi '^In-Reply-To: ' "$tmpinput"
then
echo "warning: $subject"
echo "warning: respins must be --in-reply-to=<v1.patch@message.id>."
ret=1
fi

! $verbose || printf 'Running checkpatch.pl:\n'
report=$($DPDK_CHECKPATCH_PATH $options "$tmpinput" 2>/dev/null)
if [ $? -ne 0 ] ; then
Expand Down

0 comments on commit d1cf753

Please sign in to comment.