From eb020ce29d36894c0a337eb4d6ac6d65d74b8558 Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Thu, 13 Jul 2017 13:20:13 -0700 Subject: Few fixes for mkowners.py. -) Paths should all be absolute to / -) Computing the intersection of two globs should happen with the full path in there, not just the directory's glob. --- .github/CODEOWNERS | 44 ++++++++++++++++++++++---------------------- tools/mkowners/mkowners.py | 17 ++++++++++------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5e5c26c101..de5dace21d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,25 +1,25 @@ # Auto-generated by the tools/mkowners/mkowners.py tool # Uses OWNERS files in different modules throughout the # repository as the source of truth for module ownership. -** @a11r @nicolasnoble @ctiller -bazel/** @nicolasnoble @dgquintas @ctiller -cmake/** @jtattermusch @a11r @nicolasnoble @ctiller -doc/PROTOCOL-HTTP2.md @ejona86 @a11r @nicolasnoble @ctiller -doc/interop-test-descriptions.md @ejona86 @a11r @nicolasnoble @ctiller -etc/** @jboeuf @nicolasnoble @a11r @ctiller -include/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble -src/core/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble -src/cpp/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble -src/csharp/** @jtattermusch @apolcyn @a11r @nicolasnoble @ctiller -src/node/** @murgatroid99 @a11r @nicolasnoble @ctiller -src/objective-c/** @muxi @makdharma @a11r @nicolasnoble @ctiller -src/php/** @stanley-cheung @murgatroid99 @a11r @nicolasnoble @ctiller -src/python/** @nathanielmanistaatgoogle @kpayson64 @a11r @nicolasnoble @ctiller -src/ruby/** @apolcyn @murgatroid99 @a11r @nicolasnoble @ctiller -test/build/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble -test/core/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble -test/cpp/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble -tools/** @matt-kwong @jtattermusch @nicolasnoble @a11r @ctiller -tools/codegen/core/** @ctiller @dgquintas @markdroth -tools/dockerfile/** @matt-kwong @jtattermusch @nicolasnoble @a11r @ctiller -tools/run_tests/** @matt-kwong @jtattermusch @nicolasnoble @a11r @ctiller +/** @a11r @nicolasnoble @ctiller +/bazel/** @nicolasnoble @dgquintas @ctiller +/cmake/** @jtattermusch @a11r @nicolasnoble @ctiller +/doc/PROTOCOL-HTTP2.md @ejona86 @a11r @nicolasnoble @ctiller +/doc/interop-test-descriptions.md @ejona86 @a11r @nicolasnoble @ctiller +/etc/** @jboeuf @nicolasnoble @a11r @ctiller +/include/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble +/src/core/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble +/src/cpp/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble +/src/csharp/** @jtattermusch @apolcyn @a11r @nicolasnoble @ctiller +/src/node/** @murgatroid99 @a11r @nicolasnoble @ctiller +/src/objective-c/** @muxi @makdharma @a11r @nicolasnoble @ctiller +/src/php/** @stanley-cheung @murgatroid99 @a11r @nicolasnoble @ctiller +/src/python/** @nathanielmanistaatgoogle @kpayson64 @a11r @nicolasnoble @ctiller +/src/ruby/** @apolcyn @murgatroid99 @a11r @nicolasnoble @ctiller +/test/build/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble +/test/core/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble +/test/cpp/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble +/tools/** @matt-kwong @jtattermusch @nicolasnoble @a11r @ctiller +/tools/codegen/core/** @ctiller @dgquintas @markdroth +/tools/dockerfile/** @matt-kwong @jtattermusch @nicolasnoble @a11r @ctiller +/tools/run_tests/** @matt-kwong @jtattermusch @nicolasnoble @a11r @ctiller diff --git a/tools/mkowners/mkowners.py b/tools/mkowners/mkowners.py index d4a3b56a85..18afe3a2f0 100755 --- a/tools/mkowners/mkowners.py +++ b/tools/mkowners/mkowners.py @@ -123,6 +123,9 @@ owners_data = new_owners_data # a CODEOWNERS file for GitHub # +def full_dir(rules_dir, sub_path): + return os.path.join(rules_dir, sub_path) if rules_dir != '.' else sub_path + def glob_intersect(g1, g2): if not g2: return all(c == '*' for c in g1) @@ -136,17 +139,18 @@ def glob_intersect(g1, g2): return glob_intersect(t1, g2) or glob_intersect(g1, t2) return c1 == c2 and glob_intersect(t1, t2) -def add_parent_to_globs(parent, globs): +def add_parent_to_globs(parent, globs, globs_dir): if not parent: return for owners in owners_data: if owners.dir == parent: for directive in owners.directives: for dglob in directive.globs or ['**']: for gglob, glob in globs.items(): - if glob_intersect(dglob, gglob): + if glob_intersect(full_dir(globs_dir, gglob), + full_dir(owners.dir, dglob)): if directive.who not in glob: glob.append(directive.who) - add_parent_to_globs(owners.parent, globs) + add_parent_to_globs(owners.parent, globs, globs_dir) return assert(False) @@ -167,9 +171,8 @@ with open(args.out, 'w') as out: if glob not in globs: globs[glob] = [] globs[glob].append(directive.who) - add_parent_to_globs(head.parent, globs) + add_parent_to_globs(head.parent, globs, head.dir) for glob, owners in globs.items(): - out.write('%s %s\n' % ( - os.path.join(head.dir, glob) if head.dir != '.' else glob, - ' '.join(owners))) + out.write('/%s %s\n' % ( + full_dir(head.dir, glob), ' '.join(owners))) done.add(head.dir) -- cgit v1.2.3