[PATCH] checkpatch: add check for fixes: tag

From: Philippe Schenker
Date: Wed Sep 07 2022 - 08:36:19 EST


From: Philippe Schenker <philippe.schenker@xxxxxxxxxxx>

The page about submitting patches in
Documentation/process/submitting-patches.rst is very specific on how that
tag should be formatted: 'Fixes: <12+ chars of sha1> (\"<title line>\")'

Add a rule that warns if this format does not match. This commit is
introduced as in the past commits have been sent multiple times with
having the word commit also in the Fixes: tag which had to be corrected
by the maintainers. [1]

[1] https://lore.kernel.org/all/20220906073746.1f2713f7@xxxxxxxxxxxxxxxx/
Signed-off-by: Philippe Schenker <philippe.schenker@xxxxxxxxxxx>

---

scripts/checkpatch.pl | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 79e759aac543..0d7ce0c3801a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3438,6 +3438,13 @@ sub process {
}
}

+# Check fixes tag format
+ if ($in_commit_log && ($line =~ /^\s*Fixes:/i) &&
+ !($line =~ /^\s*Fixes:\s[0-9a-f]{12,40}\s\(\".*\"\)/)) {
+ WARN("FIXES_TAG_FORMAT",
+ "Possible wrong format on Fixes: tag, please use format Fixes: <12+ chars of sha1> (\"<title line>\")\n" . $herecurr);
+ }
+
# ignore non-hunk lines and lines being removed
next if (!$hunk_line || $line =~ /^-/);

--
2.37.2