lkml.org 
[lkml]   [2018]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[RFC PATCH] checkpatch: Attempt to validate patch email subject lines
From
Date
Patch subject lines should follow the form described in
Documentation/process/submitting-patches.rst, so attempt
to validate the "Subject: " lines.

Signed-off-by: Joe Perches <joe@perches.com>
---

I tested it against the LKML "Subject:" lines I had around
(attached as subjects.gz).

I believe it's OK as many of those subjects aren't really
patches but acks and such.

Dunno if this works all that well, but perhaps it's a start.

Feedback welcomed.

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

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ce72cc4784e6..b529d8bcc2a4 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -860,6 +860,25 @@ sub is_SPDX_License_valid {
return 1;
}

+sub validate_patch_subject {
+ my ($line) = @_;
+
+ $line =~ s/^Subject:\s*//i;
+
+ return 0 if ($line =~ /^\s*\[\s*git\s+pull\s*\]/i);
+
+ # remove [RFC] or [TRIVIAL] prefix
+ $line =~ s/^\[\s*(?i:RFC|TRIVIAL)\s*\]\s*//;
+
+ # not ok if unlike [<rfc|trivial> PATCH <some tree> <vN> <x/y>]
+ return -1 if (0 == $line =~ s/^\[(?:(?i:rfc\s+trivial|rfc|trivial\s+rfc|trivial)\s+)?PATCH(?:\s+(?i:(?i:v\d+\s+[a-z-]+|v\d+|[a-z-]+)\s*))?(?:\s*\d+\/\d+)?\]\s+//);
+
+ # not ok if doesn't have 'subsystem:'
+ return -2 if (0 == $line =~ s/[\w\/\.\-]+:\s+//);
+
+ return 0;
+}
+
my $camelcase_seeded = 0;
sub seed_camelcase_includes {
return if ($camelcase_seeded);
@@ -2648,6 +2667,14 @@ sub process {
"A patch subject line should describe the change not the tool that found it\n" . $herecurr);
}

+# Check email subject [PATCH] style
+ if ($in_header_lines &&
+ $line =~ /^Subject:/i &&
+ (my $error = validate_patch_subject($line)) < 0) {
+ WARN("PATCH_SUBJECT",
+ "A patch subject line should use the form described in 'Documentation/process/submitting-patches.rst'\n" . $herecurr);
+ }
+
# Check for unwanted Gerrit info
if ($in_commit_log && $line =~ /^\s*change-id:/i) {
ERROR("GERRIT_CHANGE_ID",
[unhandled content-type:application/gzip]
\
 
 \ /
  Last update: 2018-08-08 23:04    [W:0.042 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site