All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] scripts: check commit message length to fit 75 characters
@ 2022-09-28 16:25 Denis V. Lunev
  0 siblings, 0 replies; only message in thread
From: Denis V. Lunev @ 2022-09-28 16:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Denis V. Lunev, Alexey Kardashevskiy, Philippe Mathieu-Daudé,
	Marc-André Lureau, Paolo Bonzini, Eric Blake,
	Markus Armbruster

There are a lot of commits descriptions which are rendered in the
'git log' with line wrap. Apparently, this is looking awkward. Let us
add check into checkpatch.pl for that.

I am not very good Perl developer, but there is an implementation in
Linux kernel's checkpatch.pl. Linux kernel people have faced a lot of
obstacles here thus direct port from them looks beneficial.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Alexey Kardashevskiy <aik@ozlabs.ru>
CC: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Eric Blake <eblake@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
---
 roms/SLOF             |  2 +-
 scripts/checkpatch.pl | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/roms/SLOF b/roms/SLOF
index 6b6c16b4b4..5b4c5acdcd 160000
--- a/roms/SLOF
+++ b/roms/SLOF
@@ -1 +1 @@
-Subproject commit 6b6c16b4b40763507cf1f518096f3c3883c5cf2d
+Subproject commit 5b4c5acdcd552a4e1796aeca6bb700f6cbb0282d
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d900d18048..dc5841a1aa 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -36,6 +36,18 @@ my $root;
 my %debug;
 my $help = 0;
 
+our $signature_tags = qr{(?xi:
+        Signed-off-by:|
+        Co-developed-by:|
+        Acked-by:|
+        Tested-by:|
+        Reviewed-by:|
+        Reported-by:|
+        Suggested-by:|
+        To:|
+        Cc:
+)};
+
 sub help {
 	my ($exitcode) = @_;
 
@@ -1303,6 +1315,7 @@ sub process {
 
 	my $in_header_lines = $file ? 0 : 1;
 	my $in_commit_log = 0;		#Scanning lines before patch
+    my $commit_log_long_line = 0;
 	my $reported_maintainer_file = 0;
 	my $non_utf8_charset = 0;
 
@@ -1585,6 +1598,19 @@ sub process {
 			WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr);
 		}
 
+        if ($in_commit_log && !$commit_log_long_line && length($line) > 75 &&
+                !($line =~ /^\s*[a-zA-Z0-9_\/\.]+\s+\|\s+\d+/ ||
+                            # file delta changes
+                    $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ ||
+                            # filename then :
+                    $line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i
+                            # A Fixes: or Link: line or signature tag line
+                    )) {
+            WARN("Possible unwrapped commit description (prefer a maximum " .
+                 "75 chars per line)\n" . $herecurr);
+            $commit_log_long_line = 1;
+        }
+
 # ignore non-hunk lines and lines being removed
 		next if (!$hunk_line || $line =~ /^-/);
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-28 16:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 16:25 [PATCH 1/1] scripts: check commit message length to fit 75 characters Denis V. Lunev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.