devtools: move mailmap check after patch applied

Message ID 20230327145219.1927159-1-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series devtools: move mailmap check after patch applied |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Thomas Monjalon March 27, 2023, 2:52 p.m. UTC
  The names in a patch were possibly checked with checkpatches.sh
before applying the patch, so before .mailmap file was updated.

The check is moved and translated in check-git-log.sh,
which is run only on a repository, not a detached patch file.

Fixes: e83d41f0694d ("mailmap: add list of contributors")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 devtools/check-git-log.sh | 15 +++++++++++++++
 devtools/checkpatches.sh  | 30 ------------------------------
 2 files changed, 15 insertions(+), 30 deletions(-)
  

Comments

David Marchand March 28, 2023, 1:52 p.m. UTC | #1
On Mon, Mar 27, 2023 at 4:52 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> The names in a patch were possibly checked with checkpatches.sh
> before applying the patch, so before .mailmap file was updated.
>
> The check is moved and translated in check-git-log.sh,
> which is run only on a repository, not a detached patch file.
>
> Fixes: e83d41f0694d ("mailmap: add list of contributors")
> Cc: stable@dpdk.org
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

I don't really like how we rely on the IFS= change in the middle of
check-git-log.sh, but this change works.

Reviewed-by: David Marchand <david.marchand@redhat.com>
  
Ferruh Yigit March 28, 2023, 2:27 p.m. UTC | #2
On 3/28/2023 2:52 PM, David Marchand wrote:
> On Mon, Mar 27, 2023 at 4:52 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>>
>> The names in a patch were possibly checked with checkpatches.sh
>> before applying the patch, so before .mailmap file was updated.
>>
>> The check is moved and translated in check-git-log.sh,
>> which is run only on a repository, not a detached patch file.
>>
>> Fixes: e83d41f0694d ("mailmap: add list of contributors")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> 
> I don't really like how we rely on the IFS= change in the middle of
> check-git-log.sh, but this change works.
> 
> Reviewed-by: David Marchand <david.marchand@redhat.com>
> 
> 

Tested-by: Ferruh Yigit <ferruh.yigit@amd.com>
  
Thomas Monjalon March 28, 2023, 5:11 p.m. UTC | #3
28/03/2023 16:27, Ferruh Yigit:
> On 3/28/2023 2:52 PM, David Marchand wrote:
> > On Mon, Mar 27, 2023 at 4:52 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> >>
> >> The names in a patch were possibly checked with checkpatches.sh
> >> before applying the patch, so before .mailmap file was updated.
> >>
> >> The check is moved and translated in check-git-log.sh,
> >> which is run only on a repository, not a detached patch file.
> >>
> >> Fixes: e83d41f0694d ("mailmap: add list of contributors")
> >> Cc: stable@dpdk.org
> >>
> >> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > 
> > I don't really like how we rely on the IFS= change in the middle of
> > check-git-log.sh, but this change works.
> > 
> > Reviewed-by: David Marchand <david.marchand@redhat.com>
> 
> Tested-by: Ferruh Yigit <ferruh.yigit@amd.com>

Applied
  

Patch

diff --git a/devtools/check-git-log.sh b/devtools/check-git-log.sh
index e26205814b..af751e49ab 100755
--- a/devtools/check-git-log.sh
+++ b/devtools/check-git-log.sh
@@ -259,6 +259,21 @@  done)
 [ -z "$bad" ] || { printf "Missing 'Signed-off-by:' tag: \n$bad\n"\
 	&& failure=true;}
 
+# check names
+names=$(git log --format='From: %an <%ae>%n%b' --reverse $range |
+	sed -rn 's,.*: (.*<.*@.*>),\1,p' |
+	sort -u)
+bad=$(for contributor in $names ; do
+	! grep -qE "^$contributor($| <)" $selfdir/../.mailmap || continue
+	if grep -q "^${contributor%% <*} <" .mailmap ; then
+		printf "\t$contributor is not the primary email address\n"
+	else
+		printf "\t$contributor is unknown in .mailmap\n"
+	fi
+done)
+[ -z "$bad" ] || { printf "Contributor name/email mismatch with .mailmap: \n$bad\n"\
+	&& failure=true;}
+
 total=$(echo "$commits" | wc -l)
 if $failure ; then
 	printf "\nInvalid patch(es) found - checked $total patch"
diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 1dee094c7a..a07bbc83cb 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -248,28 +248,6 @@  check_release_notes() { # <patch>
 		grep -v $current_rel_notes
 }
 
-check_names() { # <patch>
-	res=0
-
-	old_IFS=$IFS
-	IFS='
-'
-	for contributor in $(sed -rn '/^$/,/^--- / {s/.*: (.*<.*@.*>)/\1/p}' $1); do
-		! grep -qE "^$contributor($| <)" .mailmap || continue
-		name=${contributor%% <*}
-		if grep -q "^$name <" .mailmap; then
-			reason="$name mail differs from primary mail"
-		else
-			reason="$contributor is unknown"
-		fi
-		echo "$reason, please fix the commit message or update .mailmap."
-		res=1
-	done
-	IFS=$old_IFS
-
-	return $res
-}
-
 number=0
 range='origin/main..'
 quiet=false
@@ -378,14 +356,6 @@  check () { # <patch-file> <commit>
 		ret=1
 	fi
 
-	! $verbose || printf '\nChecking names in commit log:\n'
-	report=$(check_names "$tmpinput")
-	if [ $? -ne 0 ] ; then
-		$headline_printed || print_headline "$subject"
-		printf '%s\n' "$report"
-		ret=1
-	fi
-
 	if [ "$tmpinput" != "$1" ]; then
 		rm -f "$tmpinput"
 		trap - INT