From d23eaa356f9ca0b4fec09b74229b29f8d061789a Mon Sep 17 00:00:00 2001 From: Nicholas Sudsgaard Date: Fri, 10 Oct 2025 09:15:01 +0900 Subject: [PATCH] util/lint: maintainers-syntax: Add a check to ensure paths exist The MAINTAINERS file is used to automatically assign reviewers on Gerrit, however as the paths are not checked they can become out of sync with the codebase. This is detrimental to both the uploader and the maintainers, as the change may not get the appropriate attention. Fix this problem by adding a simple check for 'F' and 'X' entries. Change-Id: I7755f6317edda0d8d976e138cfafcc3ef5850ead Signed-off-by: Nicholas Sudsgaard Reviewed-on: https://review.coreboot.org/c/coreboot/+/89511 Tested-by: build bot (Jenkins) Reviewed-by: Elyes Haouas Reviewed-by: Angel Pons --- util/lint/lint-stable-027-maintainers-syntax | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/util/lint/lint-stable-027-maintainers-syntax b/util/lint/lint-stable-027-maintainers-syntax index 85245d1247..d0753d7316 100755 --- a/util/lint/lint-stable-027-maintainers-syntax +++ b/util/lint/lint-stable-027-maintainers-syntax @@ -1,21 +1,34 @@ #!/usr/bin/env perl # SPDX-License-Identifier: GPL-2.0-or-later # -# DESCR: Check that path patterns in MAINTAINERS have trailing slash +# DESCR: Check the syntax of the MAINTAINERS file use strict; use warnings; +sub check_path { + my ($path) = @_; + + if ( ! -e $path ) { + print "MAINTAINERS:$. No such file or directory exists "; + print "`$path`\n"; + } +} + 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 * + if ( $line =~ /^[FX]:\s+([^\s]*)\s+$/ ) { my $path = $1; - if ( -d $path ) { + # Match path patterns not ending with '/' or '*'. This cannot be done + # in check_path(), as it only works on pre-globbed paths. + if ( $path =~ /[^*\/\s]$/ && -d $path ) { print "MAINTAINERS:$. missing trailing slash for directory match "; print "`$path`\n"; } + + check_path($_) foreach ( glob $path ); } }