summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMichael Niewöhner <foss@mniewoehner.de>2021-04-09 16:26:32 +0200
committerPatrick Georgi <pgeorgi@google.com>2021-04-13 14:29:43 +0000
commit64d31f48d276aa491976fa7b0a8b1eddf9347ca9 (patch)
tree59af639296ef3a4f0a7f2c93f2278b458c6c8dcb /util
parent2b4da16ea410c7536ec7cb9f600877ec5ae8e502 (diff)
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>
Diffstat (limited to 'util')
-rwxr-xr-xutil/lint/lint-stable-027-maintainers-syntax22
1 files changed, 22 insertions, 0 deletions
diff --git a/util/lint/lint-stable-027-maintainers-syntax b/util/lint/lint-stable-027-maintainers-syntax
new file mode 100755
index 0000000000..85245d1247
--- /dev/null
+++ b/util/lint/lint-stable-027-maintainers-syntax
@@ -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);