forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcheck_maintainers.py
executable file
·72 lines (56 loc) · 2.07 KB
/
check_maintainers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
# Copyright (c) 2024 Vestas Wind Systems A/S
#
# SPDX-License-Identifier: Apache-2.0
import argparse
import sys
from get_maintainer import Maintainers
from github.GithubException import UnknownObjectException
from github_helpers import get_github_object
def parse_args():
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description=__doc__, allow_abbrev=False)
parser.add_argument(
"-m", "--maintainers",
metavar="MAINTAINERS_FILE",
help="Maintainers file to load. If not specified, MAINTAINERS.yml in "
"the top-level repository directory is used, and must exist. "
"Paths in the maintainers file will always be taken as relative "
"to the top-level directory.")
return parser.parse_args()
def main() -> None:
args = parse_args()
zephyr_repo = get_github_object().get_repo('zephyrproject-rtos/zephyr')
maintainers = Maintainers(args.maintainers)
gh = get_github_object()
gh_users = []
notfound = []
noncollabs = []
for area in maintainers.areas.values():
gh_users = list(set(gh_users + area.maintainers + area.collaborators))
gh_users.sort()
print('Checking maintainer and collaborator user accounts on GitHub:')
for gh_user in gh_users:
try:
print('.', end='', flush=True)
gh.get_user(gh_user)
if not zephyr_repo.has_in_collaborators(gh_user):
noncollabs.append(gh_user)
except UnknownObjectException:
notfound.append(gh_user)
print('\n')
if notfound:
print('The following GitHub user accounts do not exist:')
print('\n'.join(notfound))
else:
print('No non-existing user accounts found')
if noncollabs:
print('The following GitHub user accounts are not collaborators:')
print('\n'.join(noncollabs))
else:
print('No non-collaborator user accounts found')
if notfound or noncollabs:
sys.exit(1)
if __name__ == '__main__':
main()