summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2018-11-12 18:49:09 +0100
committerPatrick Georgi <pgeorgi@google.com>2018-11-13 17:44:36 +0000
commite874df9e0be1c61dceede3084f18ac7d49655cfc (patch)
tree2f9668cea8a84259ff46be8bb49288351549f1ca /util
parent62a27385fdf770113972793bfffa8514d602144d (diff)
downloadcoreboot-e874df9e0be1c61dceede3084f18ac7d49655cfc.tar.xz
util/scripts/maintainers.go: Add Gerrit reviewers config emitter
The gerrit reviewers plugin has a certain configuration format. Teach maintainers to emit it when called with -print-gerrit-rules. Change-Id: I92cfc905e0c1b03b7cf793a4324c392140a22060 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/29607 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/scripts/maintainers.go41
1 files changed, 38 insertions, 3 deletions
diff --git a/util/scripts/maintainers.go b/util/scripts/maintainers.go
index e4c2387398..e0055e1cf0 100644
--- a/util/scripts/maintainers.go
+++ b/util/scripts/maintainers.go
@@ -258,11 +258,41 @@ func glob_to_regex(glob string) string {
return "^" + regex + "$"
}
+var is_email *regexp.Regexp
+
+func extract_maintainer(maintainer string) string {
+ if is_email == nil {
+ is_email = regexp.MustCompile("<[^>]*>")
+ }
+
+ if match := is_email.FindStringSubmatch(maintainer); match != nil {
+ return match[0][1 : len(match[0])-1]
+ }
+ return maintainer
+}
+
+func do_print_gerrit_rules() {
+ for _, subsystem := range subsystems {
+ if len(subsystem.paths) == 0 || len(subsystem.maintainer) == 0 {
+ continue
+ }
+ fmt.Println("#", subsystem.name)
+ for _, path := range subsystem.paths {
+ fmt.Println("[filter \"file:" + path_to_regexstr(path) + "\"]")
+ for _, maint := range subsystem.maintainer {
+ fmt.Println(" reviewer =", extract_maintainer(maint))
+ }
+ }
+ fmt.Println()
+ }
+}
+
func main() {
var (
- files []string
- err error
- debug = flag.Bool("debug", false, "emit additional debug output")
+ files []string
+ err error
+ print_gerrit_rules = flag.Bool("print-gerrit-rules", false, "emit the MAINTAINERS rules in a format suitable for Gerrit's reviewers plugin")
+ debug = flag.Bool("debug", false, "emit additional debug output")
)
flag.Parse()
@@ -278,6 +308,11 @@ func main() {
print_maintainers()
}
+ if *print_gerrit_rules {
+ do_print_gerrit_rules()
+ return
+ }
+
args := flag.Args()
if len(args) == 0 {
/* get the filenames */