Add CODEOWNERS support
This commit is contained in:
parent
c4a891d425
commit
65fd33ec0e
4 changed files with 14 additions and 5 deletions
2
CODEOWNERS
Normal file
2
CODEOWNERS
Normal file
|
@ -0,0 +1,2 @@
|
|||
* @qmk/collaborators
|
||||
/lib/python/* @skullydazed @erovia
|
|
@ -17,7 +17,7 @@ def ping_maintainers(cli):
|
|||
for file in cli.args.files:
|
||||
for maintainer in maintainers(file):
|
||||
if maintainer != 'qmk/collaborators':
|
||||
github_maintainers.add('@' + maintainer)
|
||||
github_maintainers.add(maintainer)
|
||||
|
||||
if github_maintainers:
|
||||
print(f'If you were pinged by this comment you have one or more files being changed by this PR: {" ".join(sorted(github_maintainers))}')
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
from pathlib import Path
|
||||
|
||||
from codeowners import CodeOwners
|
||||
|
||||
from qmk.json_schema import json_load
|
||||
|
||||
codeowners_file = Path('CODEOWNERS')
|
||||
codeowners = CodeOwners(codeowners_file.read_text())
|
||||
|
||||
|
||||
def maintainers(file):
|
||||
"""Yields maintainers for a file.
|
||||
"""
|
||||
maintainers = 'qmk'
|
||||
maintainers = [owner[1] for owner in codeowners.of(str(file))]
|
||||
file_dir = file if file.is_dir() else file.parent
|
||||
|
||||
cur_path = Path('.')
|
||||
|
@ -16,7 +21,8 @@ def maintainers(file):
|
|||
info_file = cur_path / 'info.json'
|
||||
if info_file.exists():
|
||||
new_info_data = json_load(info_file)
|
||||
maintainers = new_info_data.get('maintainer', maintainers)
|
||||
maintainers = new_info_data.get('maintainer').replace(',', ' ').split()
|
||||
maintainers = ['@' + maintainer for maintainer in maintainers]
|
||||
|
||||
for maintainer in maintainers.replace(',', ' ').split():
|
||||
yield 'qmk/collaborators' if maintainer == 'qmk' else maintainer
|
||||
for maintainer in maintainers:
|
||||
yield '@qmk/collaborators' if maintainer == 'qmk' else maintainer
|
|
@ -2,6 +2,7 @@
|
|||
-r requirements.txt
|
||||
|
||||
# Python development requirements
|
||||
codeowners
|
||||
nose2
|
||||
flake8
|
||||
pep8-naming
|
||||
|
|
Loading…
Reference in a new issue