lint: MAINTAINERS: check path matches to not only cover the directory
Gerrit is able to add reviewers based on entries in the `MAINTAINERS` file. For inclusion and exclusion matches either paths or regular expressions can be used. The syntax is described in the header of the file. When matching a path, there are two sensible possibilities: - `path/to/file` matches a file. - `path/to/dir/` matches a folder including its contents recursively. - `path/to/dir/*` matches all files in that folder, without recursing into its subfolders. The trailing slash in the second example is essential. Without it, only the directory entry itself matches when, for example, the folder gets deleted, renamed or its permissions get modified. Reviewers in the list won't get added to changes of any files or directories below that path. Thus, add a linter script to ensure a path match on a directory always ends with `/` or `/*` as shown above. Change-Id: I9873184c0df4a0b4455f803828e2719887e545db Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/52210 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
parent
2b4da16ea4
commit
64d31f48d2
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env perl
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#
|
||||
# DESCR: Check that path patterns in MAINTAINERS have trailing slash
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
open( my $file, "<", "MAINTAINERS" ) or die "Error: could not open file 'MAINTAINERS'\n";
|
||||
|
||||
while ( my $line = <$file> ) {
|
||||
if ( $line =~ /^[FX]:\s+([^\s]*[^*\/\s])\s+$/ ) { # path patterns not ending with / or *
|
||||
my $path = $1;
|
||||
|
||||
if ( -d $path ) {
|
||||
print "MAINTAINERS:$. missing trailing slash for directory match ";
|
||||
print "`$path`\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close($file);
|
Loading…
Reference in New Issue