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>
This commit is contained in:
parent
158fed9ee7
commit
a0c7f34302
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue