diff options
author | Michael Niewöhner <foss@mniewoehner.de> | 2021-04-13 00:44:21 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2021-04-14 12:18:58 +0000 |
commit | a0c7f343021aeef12499fca6d0fadecab7e75bb1 (patch) | |
tree | 0d40e347d8ba825cd54fcfa4ad157fa83f4b8135 /util/scripts | |
parent | 158fed9ee72ff09b5f8237c42910b406727caa9c (diff) |
maintainers.go: Work around common mistake in MAINTAINERS
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 <foss@mniewoehner.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52276
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/scripts')
-rw-r--r-- | util/scripts/maintainers.go | 8 |
1 files changed, 8 insertions, 0 deletions
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 */ |