]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
support/scripts: `checkpatch` `WARN` on commit subject > 70 chars
authorSergiu Moga <sergiu@unikraft.io>
Wed, 30 Aug 2023 17:54:07 +0000 (20:54 +0300)
committerRazvan Deaconescu <razvand@unikraft.io>
Fri, 20 Oct 2023 16:32:28 +0000 (19:32 +0300)
Although `checkpatch.pl` checks for commit message lines to not be
longer than `75` characters, in the case of `Github`'s UI, a commit
subject longer than `70` character results in its line overflowing
into the next.
E.g.
```
[Selector]/[Component]: Lorem ipsum dolor sit amet, consectetuer adipiscin
```
becomes
```
[Selector]/[Component]: Lorem ipsum dolor sit amet, consectetuer adip...
...iscin
```

Since this is not aesthetically pleasing, enforce a character limit for
commit message subjects to not be longer than `70` characters.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1077

support/scripts/checkpatch.pl

index 127cd6efd9ebc6ffba28fde272b5bb33924e53af..66c60825341101236b37c581de119e64d1c4ee96 100755 (executable)
@@ -2548,6 +2548,25 @@ sub process {
                             "Patch subject line does not follow Unikraft scheme: '[Selector]/[Component]: [Short message]'\n" . $herecurr);
                }
 
+# Check that the first line in the commit message has less than
+# 70 characters to comply with Github UI. This helps
+# avoid commit message subjects placed at the beginning
+# to overflow into the second line when viewing through
+# the Github UI.
+               if ($in_header_lines &&
+                   $line =~ /^Subject:.*$/i) {
+                       my $commit_subject_line0 = $1 if
+                               $lines[$linenr - 1] =~ /^Subject: \[.*\] (.*)$/;
+                       my $commit_subject_line1 = $lines[$linenr];
+                       my $commit_subject = $commit_subject_line0 .
+                                            $commit_subject_line1;
+                       if (length($commit_subject) > 70) {
+                               WARN("COMMIT_SUBJECT_LONG_LINE",
+                                    "Possible unwrapped commit subject (prefer a maximum 70 chars)\n" . $commit_subject);
+                               $commit_log_long_line = 1;
+                       }
+               }
+
 # Check for old stable address
                if ($line =~ /^\s*cc:\s*.*<?\bstable\@kernel\.org\b>?.*$/i) {
                        ERROR("STABLE_ADDRESS",