Skip to content

Commit f32c3e0

Browse files
committed
branch_worker: rename email_in_submitter_allowlist
Rename email_in_submitter_allowlist to email_matches_any to reflect its wider applicability. Signed-off-by: Ihor Solodrai <[email protected]>
1 parent ccece32 commit f32c3e0

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

kernel_patches_daemon/branch_worker.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,8 @@ def generate_msg_id(host: str) -> str:
257257
return f"{checksum}@{host}"
258258

259259

260-
def email_in_submitter_allowlist(email: str, allowlist: Sequence[re.Pattern]) -> bool:
261-
"""
262-
Checks if an email is in the submitter allowlist
263-
264-
Note that there may be false positives when folks have regex syntax in
265-
their email address. But that is ok -- this is simply a rollout mechanism.
266-
We only need to roughly control the rollout.
267-
"""
268-
return any(regex.fullmatch(email) for regex in allowlist)
260+
def email_matches_any(email: str, patterns: Sequence[re.Pattern]) -> bool:
261+
return any(regex.fullmatch(email) for regex in patterns)
269262

270263

271264
def build_email(
@@ -356,7 +349,7 @@ def ci_results_email_recipients(
356349
) -> Tuple[List[str], List[str]]:
357350
to_list = copy.copy(config.smtp_to)
358351
cc_list = copy.copy(config.smtp_cc)
359-
if config.ignore_allowlist or email_in_submitter_allowlist(
352+
if config.ignore_allowlist or email_matches_any(
360353
series.submitter_email, config.submitter_allowlist
361354
):
362355
to_list += [series.submitter_email]

tests/test_branch_worker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
build_email,
3232
ci_results_email_recipients,
3333
create_color_labels,
34-
email_in_submitter_allowlist,
34+
email_matches_any,
3535
EmailBodyContext,
3636
furnish_ci_email_body,
3737
get_ci_base,
@@ -1249,7 +1249,7 @@ def test_allowlist_non_regex(self):
12491249

12501250
for email, expected in cases:
12511251
with self.subTest(msg=email):
1252-
result = email_in_submitter_allowlist(email, allowlist)
1252+
result = email_matches_any(email, allowlist)
12531253
self.assertEqual(result, expected)
12541254

12551255
def test_allowlist_regex_match(self):
@@ -1270,7 +1270,7 @@ def test_allowlist_regex_match(self):
12701270

12711271
for email, expected in cases:
12721272
with self.subTest(msg=email):
1273-
result = email_in_submitter_allowlist(email, allowlist)
1273+
result = email_matches_any(email, allowlist)
12741274
self.assertEqual(result, expected)
12751275

12761276
def test_email_submitter_in_allowlist(self):

0 commit comments

Comments
 (0)