* [RFC PATCH] checkpatch: Attempt to validate patch email subject lines
@ 2018-08-08 21:03 Joe Perches
0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2018-08-08 21:03 UTC (permalink / raw)
To: Andrew Morton, Andy Whitcroft; +Cc: Greg KH, LKML
[-- Attachment #1: Type: text/plain, Size: 2008 bytes --]
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",
[-- Attachment #2: subjects.gz --]
[-- Type: application/gzip, Size: 307209 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-08-08 21:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-08 21:03 [RFC PATCH] checkpatch: Attempt to validate patch email subject lines Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®