Skip to content

Commit 83132c7

Browse files
committed
Revert "ci: set_assignee: add release team on PRs without review"
Script does not handle already assigned PRs correctly, revert until we have a proper fix. This reverts commit 972ebb6. Signed-off-by: Anas Nashif <[email protected]>
1 parent 3232354 commit 83132c7

File tree

1 file changed

+2
-76
lines changed

1 file changed

+2
-76
lines changed

scripts/set_assignees.py

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
import argparse
77
import datetime
8-
import hashlib
98
import os
10-
import re
119
import sys
1210
import time
1311
from collections import defaultdict
@@ -28,49 +26,6 @@ def log(s):
2826
print(s, file=sys.stdout)
2927

3028

31-
SIGN_PREFIX = "<!--bot-signature:"
32-
SIGN_SUFFIX = "-->"
33-
34-
def normalize(text: str) -> str:
35-
text = text.replace('\r\n', '\n').strip()
36-
text = re.sub(r'[ \t]+', ' ', text)
37-
text = re.sub(r'\n{3,}', '\n\n', text)
38-
return text
39-
40-
def make_signature(body: str, tag: str = "default") -> str:
41-
h = hashlib.sha256(normalize(body).encode("utf-8")).hexdigest()[:16]
42-
return f"{SIGN_PREFIX}{tag}:{h}{SIGN_SUFFIX}"
43-
44-
def post_or_update_signed_comment(pr, body: str, tag: str = "default", update_if_found=True):
45-
issue = pr.as_issue()
46-
sig = make_signature(body, tag)
47-
signed_body = f"{body}\n\n{sig}"
48-
49-
# Try to detect the bot/user login for “same author” filtering
50-
try:
51-
me = pr.base.repo._requester._Requester__authorizationProvider.user.login
52-
except Exception:
53-
me = None
54-
55-
existing = None
56-
for c in issue.get_comments():
57-
if me and c.user.login != me:
58-
continue
59-
if sig in c.body:
60-
existing = c
61-
break
62-
63-
if existing:
64-
if update_if_found and normalize(existing.body) != normalize(signed_body):
65-
existing.edit(signed_body)
66-
print("Updated existing signed comment.")
67-
return existing
68-
print("Signed comment already present, skipping.")
69-
return existing
70-
71-
# No signed comment found → create new
72-
return issue.create_comment(signed_body)
73-
7429
def parse_args():
7530
global args
7631
parser = argparse.ArgumentParser(
@@ -295,7 +250,6 @@ def process_pr(gh, maintainer_file, number):
295250
else:
296251
log("Too many labels to be applied")
297252

298-
reviewers_added = False
299253
if collab:
300254
reviewers = []
301255
existing_reviewers = set()
@@ -343,19 +297,15 @@ def process_pr(gh, maintainer_file, number):
343297
reviewers = list(_all_maintainers.keys())
344298

345299
if reviewers:
346-
reviewers_added = True
347300
try:
348301
log(f"adding reviewers {reviewers}...")
349302
if not args.dry_run:
350303
pr.create_review_request(reviewers=reviewers)
351304
except GithubException:
352-
log("can't add reviewers")
353-
else:
354-
log("no reviewers to add")
305+
log("can't add reviewer")
355306

356307
ms = []
357308
# assignees
358-
assignees_added = False
359309
if assignees and (not pr.assignee or args.dry_run):
360310
try:
361311
for assignee in assignees:
@@ -365,36 +315,12 @@ def process_pr(gh, maintainer_file, number):
365315
log("Error: Unknown user")
366316

367317
for mm in ms:
368-
assignees_added = True
369318
log(f"Adding assignee {mm}...")
370319
if not args.dry_run:
371-
try:
372-
pr.add_to_assignees(mm)
373-
except GithubException:
374-
log("can't add assignees.")
320+
pr.add_to_assignees(mm)
375321
else:
376322
log("not setting assignee")
377323

378-
379-
teams = [
380-
"release",
381-
]
382-
if not (assignees_added or reviewers_added):
383-
log("No assignees or reviewers could be found, adding triage team")
384-
# if we could not find any assignees or reviewers, add a comment to the PR
385-
# and add release as reviewer to make sure someone looks at it.
386-
if not args.dry_run:
387-
team = teams[0]
388-
# Use a comment with a signature so that we can update it if needed
389-
comment = (
390-
f"Could not find any assignees or reviewers for this PR, adding "
391-
f"@zephyrproject-rtos/{team} as reviewer to make sure someone looks at it. "
392-
f"@zephyrproject-rtos/{team}, please triage and assign this PR "
393-
f"appropriately. Thanks!"
394-
)
395-
post_or_update_signed_comment(pr, comment, tag="triage")
396-
pr.create_review_request(team_reviewers=teams)
397-
398324
time.sleep(1)
399325

400326

0 commit comments

Comments
 (0)