From a0c7f343021aeef12499fca6d0fadecab7e75bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Niew=C3=B6hner?= Date: Tue, 13 Apr 2021 00:44:21 +0200 Subject: maintainers.go: Work around common mistake in MAINTAINERS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. However, from time to time entries get added without this trailing slash. Thus, implement a workaround in `maintainers.go` to check, if a path entry is actually a directory. In such case a trailing slash gets appended, so that the contents will match, too. Example: `path/to/dir` will become `path/to/dir/` Tests: 1. output before and after does not differ 2. manual test of resulting regex when running `maintainers.go` Change-Id: Ic712aacb0c5c50380fa9beeccf5161501f1cd8ea Signed-off-by: Michael Niewöhner Reviewed-on: https://review.coreboot.org/c/coreboot/+/52276 Reviewed-by: Patrick Georgi Reviewed-by: Nico Huber Tested-by: build bot (Jenkins) --- util/scripts/maintainers.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'util/scripts') diff --git a/util/scripts/maintainers.go b/util/scripts/maintainers.go index c68ea058f0..53beb2ccf7 100644 --- a/util/scripts/maintainers.go +++ b/util/scripts/maintainers.go @@ -77,6 +77,14 @@ func get_maintainers() ([]string, error) { } func path_to_regexstr(path string) string { + /* Add missing trailing slash if path is a directory */ + if path[len(path)-1] != '/' { + fileInfo, err := os.Stat(path) + if err == nil && fileInfo.IsDir() { + path += "/" + } + } + regexstr := glob_to_regex(path) /* Handle path with trailing '/' as prefix */ -- cgit v1.2.3