]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
GHA: make the spacecheck say line number for trailing space errors
authorDaniel Stenberg <daniel@haxx.se>
Sun, 29 Jun 2025 12:48:05 +0000 (14:48 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 29 Jun 2025 14:43:41 +0000 (16:43 +0200)
As it can be quite confusing and frustrating without it.

Closes #17777

.github/scripts/spacecheck.pl

index 6e2488d28f34f12c6071058e29fb751866fb4607..10bd2fc8ed76a1a8ed3f0a66768852877a933faa 100755 (executable)
@@ -131,8 +131,14 @@ while(my $filename = <$git_ls_files>) {
     }
 
     if(!fn_match($filename, @space_at_eol) &&
-        $content =~ /[ \t]\n/) {
-        push @err, "content: has line-ending whitespace";
+       $content =~ /[ \t]\n/) {
+        my $line;
+        for my $l (split(/\n/, $content)) {
+            $line++;
+            if($l =~ /[ \t]$/) {
+                push @err, "line $line: trailing whitespace";
+            }
+        }
     }
 
     if($content ne "" &&