Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make update_owners.py assign new tests to self by default. #35743

Merged
merged 1 commit into from
Oct 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 20 additions & 7 deletions hack/update_owners.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,19 @@ def get_maintainers():
return sorted(ret - SKIP_MAINTAINERS)


def detect_github_username():
remotes = subprocess.check_output(['git', 'remote', '-v'])
repos = set(re.findall(r'\w+(?=/kubernetes)', remotes))
repos.remove('kubernetes')
if len(repos) == 1:
return repos.pop()
raise ValueError('unable to guess GitHub user from `git remote -v` output, use --user instead')


def main():
parser = argparse.ArgumentParser()
parser.add_argument('--history', action='store_true', help='Generate test list from result history.')
parser.add_argument('--user', help='User to assign new tests to (default: random).')
parser.add_argument('--user', help='User to assign new tests to (or RANDOM, default: current GitHub user).')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer we just delete remove --user=RANDOM entirely.

parser.add_argument('--check', action='store_true', help='Exit with a nonzero status if the test list has changed.')
options = parser.parse_args()

Expand Down Expand Up @@ -148,6 +157,9 @@ def main():
sys.exit(1)
sys.exit(0)

if not options.user:
options.user = detect_github_username()

for name in outdated_tests:
owners.pop(name)

Expand All @@ -164,17 +176,18 @@ def main():
if owner in maintainers)
for test_name in set(test_names) - set(owners):
random_assignment = True
if options.user:
if options.user.lower() == 'random':
new_owner, _count = random.choice(owner_counts.most_common()[-4:])
else:
new_owner = options.user
random_assignment = False
else:
new_owner, _count = random.choice(owner_counts.most_common()[-4:])
owner_counts[new_owner] += 1
owners[test_name] = (new_owner, random_assignment)

print '# Tests per maintainer:'
for owner, count in owner_counts.most_common():
print '%-20s %3d' % (owner, count)
if options.user.lower() == 'random':
print '# Tests per maintainer:'
for owner, count in owner_counts.most_common():
print '%-20s %3d' % (owner, count)

write_owners(OWNERS_PATH, owners)

Expand Down