mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-03 21:00:08 +06:00
Don't auto-assign reviewers when the author is in HF (#37500)
* Don't auto-assign reviewers when the author is in HF * Trigger tests
This commit is contained in:
parent
8ab296501a
commit
4e63a1747c
18
.github/scripts/assign_reviewers.py
vendored
18
.github/scripts/assign_reviewers.py
vendored
@ -54,6 +54,21 @@ def get_file_owners(file_path, codeowners_lines):
|
|||||||
return owners # Remember, can still be empty!
|
return owners # Remember, can still be empty!
|
||||||
return [] # Should never happen, but just in case
|
return [] # Should never happen, but just in case
|
||||||
|
|
||||||
|
def pr_author_is_in_hf(pr_author, codeowners_lines):
|
||||||
|
# Check if the PR author is in the codeowners file
|
||||||
|
for line in codeowners_lines:
|
||||||
|
line = line.split('#')[0].strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Split into pattern and owners
|
||||||
|
parts = line.split()
|
||||||
|
owners = [owner.removeprefix("@") for owner in parts[1:]]
|
||||||
|
|
||||||
|
if pr_author in owners:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
script_dir = Path(__file__).parent.absolute()
|
script_dir = Path(__file__).parent.absolute()
|
||||||
with open(script_dir / "codeowners_for_review_action") as f:
|
with open(script_dir / "codeowners_for_review_action") as f:
|
||||||
@ -68,6 +83,9 @@ def main():
|
|||||||
pr_number = event['pull_request']['number']
|
pr_number = event['pull_request']['number']
|
||||||
pr = repo.get_pull(pr_number)
|
pr = repo.get_pull(pr_number)
|
||||||
pr_author = pr.user.login
|
pr_author = pr.user.login
|
||||||
|
if pr_author_is_in_hf(pr_author, codeowners_lines):
|
||||||
|
print(f"PR author {pr_author} is in codeowners, skipping review request.")
|
||||||
|
return
|
||||||
|
|
||||||
existing_reviews = list(pr.get_reviews())
|
existing_reviews = list(pr.get_reviews())
|
||||||
if existing_reviews:
|
if existing_reviews:
|
||||||
|
Loading…
Reference in New Issue
Block a user