Merge pull request #11828 from ctiller/mosiblings

Fix a few bugs in mkowners
reviewable/pr11816/r3
Craig Tiller 8 years ago committed by GitHub
commit 5eb70d3015
  1. 5
      .github/CODEOWNERS
  2. 2
      OWNERS
  3. 2
      examples/objective-c/OWNERS
  4. 30
      tools/mkowners/mkowners.py

@ -2,17 +2,20 @@
# Uses OWNERS files in different modules throughout the
# repository as the source of truth for module ownership.
/** @a11r @nicolasnoble @ctiller
/*.podspec @muxi @makdharma @a11r @nicolasnoble @ctiller
/binding.gyp @murgatroid99 @a11r @nicolasnoble @ctiller
/Gemfile @murgatroid99 @a11r @nicolasnoble @ctiller
/grpc.gemspec @murgatroid99 @a11r @nicolasnoble @ctiller
/package.json @murgatroid99 @a11r @nicolasnoble @ctiller
/Rakefile @murgatroid99 @a11r @nicolasnoble @ctiller
/grpc.bzl @muxi @makdharma @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
/examples/node/** @murgatroid99 @a11r @nicolasnoble @ctiller
/examples/objective-c/** @muxi @makdharma @a11r @nicolasnoble @ctiller
/examples/python/** @nathanielmanistaatgoogle @kpayson64 @mehrdada
/include/** @ctiller @markdroth @dgquintas @a11r @nicolasnoble
/src/core/** @ctiller @markdroth @dgquintas
@ -34,7 +37,5 @@
/tools/** @matt-kwong @jtattermusch @nicolasnoble @a11r @ctiller
/tools/codegen/core/** @ctiller @dgquintas @markdroth
/tools/distrib/python/** @nathanielmanistaatgoogle @kpayson64 @mehrdada
/tools/dockerfile/** @matt-kwong @jtattermusch @nicolasnoble @a11r @ctiller
/tools/run_tests/** @matt-kwong @jtattermusch @nicolasnoble @a11r @ctiller
/tools/run_tests/artifacts/*_node* @murgatroid99 @matt-kwong @jtattermusch @nicolasnoble @a11r @ctiller
/tools/run_tests/helper_scripts/*_node* @murgatroid99 @matt-kwong @jtattermusch @nicolasnoble @a11r @ctiller

@ -5,3 +5,5 @@
@ctiller
@murgatroid99 binding.gyp Gemfile grpc.gemspec package.json Rakefile
@muxi *.podspec grpc.bzl
@makdharma *.podspec grpc.bzl

@ -0,0 +1,2 @@
@muxi
@makdharma

@ -132,7 +132,7 @@ def git_glob(glob):
global gg_cache
if glob in gg_cache: return gg_cache[glob]
r = set(subprocess
.check_output(['git', 'ls-files', glob])
.check_output(['git', 'ls-files', os.path.join(git_root, glob)])
.decode('utf-8')
.strip()
.splitlines())
@ -150,7 +150,7 @@ def expand_directives(root, directives):
globs[glob].append(directive.who)
# expand owners for intersecting globs
sorted_globs = sorted(globs.keys(),
key=lambda g: len(git_glob(os.path.join(root, g))),
key=lambda g: len(git_glob(full_dir(root, g))),
reverse=True)
out_globs = collections.OrderedDict()
for glob_add in sorted_globs:
@ -162,8 +162,9 @@ def expand_directives(root, directives):
files_have = git_glob(full_dir(root, glob_have))
intersect = files_have.intersection(files_add)
if intersect:
for f in files_add:
for f in sorted(files_add): # sorted to ensure merge stability
if f not in intersect:
print("X", root, glob_add, glob_have)
out_globs[os.path.relpath(f, start=root)] = who_add
for who in who_have:
if who not in out_globs[glob_add]:
@ -182,8 +183,9 @@ def add_parent_to_globs(parent, globs, globs_dir):
intersect = files_parent.intersection(files_child)
gglob_who_orig = gglob_who.copy()
if intersect:
for f in files_child:
for f in sorted(files_child): # sorted to ensure merge stability
if f not in intersect:
print("Y", full_dir(owners.dir, oglob), full_dir(globs_dir, gglob))
who = gglob_who_orig.copy()
globs[os.path.relpath(f, start=globs_dir)] = who
for who in oglob_who:
@ -199,6 +201,7 @@ with open(args.out, 'w') as out:
out.write('# Auto-generated by the tools/mkowners/mkowners.py tool\n')
out.write('# Uses OWNERS files in different modules throughout the\n')
out.write('# repository as the source of truth for module ownership.\n')
written_globs = []
while todo:
head, *todo = todo
if head.parent and not head.parent in done:
@ -207,6 +210,21 @@ with open(args.out, 'w') as out:
globs = expand_directives(head.dir, head.directives)
add_parent_to_globs(head.parent, globs, head.dir)
for glob, owners in globs.items():
out.write('/%s %s\n' % (
full_dir(head.dir, glob), ' '.join(owners)))
skip = False
for glob1, owners1, dir1 in reversed(written_globs):
files = git_glob(full_dir(head.dir, glob))
files1 = git_glob(full_dir(dir1, glob1))
intersect = files.intersection(files1)
if files == intersect:
if sorted(owners) == sorted(owners1):
skip = True # nothing new in this rule
break
elif intersect:
# continuing would cause a semantic change since some files are
# affected differently by this rule and CODEOWNERS is order dependent
break
if not skip:
out.write('/%s %s\n' % (
full_dir(head.dir, glob), ' '.join(owners)))
written_globs.append((glob, owners, head.dir))
done.add(head.dir)

Loading…
Cancel
Save