[tools] Ignore bot generated patches

This is a fix for the test whether a patch is bot generated or not, as
that did not worked as intended. The problem is that the script is
checking the email address of the parent patch (HEAD~), which probably
should be right in case the patch would be a MERGE patch. But this is
wrong in case the patch is not a MERGE patch. This fix uses the very
same pattern as it is using for the commit message parsing: the
$commit_hash variable, which is the parent's commit hash if the patch
is a MERGE patch, and an empty string in the other case (causing to
call 'git show' on HEAD).

Change-Id: I0abc72180edf34a6dd0624a40fb8682397805eca
This commit is contained in:
Elod Illes 2024-07-12 22:53:06 +02:00
parent c6d8c6972d
commit b8f3975d36

View File

@ -14,7 +14,7 @@ if [ $parent_number -eq 2 ]; then
commit_hash=$(git show --format='%P' --quiet | awk '{print $NF}') commit_hash=$(git show --format='%P' --quiet | awk '{print $NF}')
fi fi
if git show --format='%aE' HEAD~ --quiet | grep -qi 'infra-root@openstack.org'; then if git show --format='%aE' --quiet $commit_hash | grep -qi 'infra-root@openstack.org'; then
echo 'Bot generated change; ignoring' echo 'Bot generated change; ignoring'
exit 0 exit 0
fi fi