From 4aab4c28d7590cc49c8106f6d66b4a71d8b3635a Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Fri, 24 Jul 2026 21:50:23 -0700 Subject: [PATCH] fix(scripts): accept legacy consecutive-hyphen GitHub logins in add_contributor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub's current signup rules forbid consecutive hyphens, but legacy accounts with them exist and are valid (Roger--Han, hit live during the July 24 sweep — the mapping had to be written by hand). Accept any alphanumeric/hyphen login that doesn't start or end with a hyphen. --- scripts/add_contributor.py | 6 +++++- tests/scripts/test_contributor_map.py | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/add_contributor.py b/scripts/add_contributor.py index 8192fe4f55c4..cb64b331cbb4 100644 --- a/scripts/add_contributor.py +++ b/scripts/add_contributor.py @@ -25,7 +25,11 @@ REPO_ROOT = Path(__file__).resolve().parent.parent EMAILS_DIR = REPO_ROOT / "contributors" / "emails" _EMAIL_RE = re.compile(r"^[^/\\\s]+@[^/\\\s]+$") -_LOGIN_RE = re.compile(r"^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$") +# GitHub's *current* signup rules forbid consecutive hyphens, but legacy +# accounts with them exist and are valid (e.g. Roger--Han, verified via the +# users API July 2026). Accept any alphanumeric/hyphen login that doesn't +# start or end with a hyphen, max 39 chars. +_LOGIN_RE = re.compile(r"^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$") def read_mapping_file(path: Path) -> str | None: diff --git a/tests/scripts/test_contributor_map.py b/tests/scripts/test_contributor_map.py index 3109a5e31434..655210aa9895 100644 --- a/tests/scripts/test_contributor_map.py +++ b/tests/scripts/test_contributor_map.py @@ -114,6 +114,15 @@ def test_add_rejects_invalid_email_and_login(emails_dir): ) +def test_add_accepts_legacy_consecutive_hyphen_login(emails_dir): + # Legacy GitHub accounts with consecutive hyphens are real (Roger--Han); + # current signup rules forbid them but existing logins remain valid. + assert add_contributor("roger.hanhong@gmail.com", "Roger--Han") == 0 + assert (emails_dir / "roger.hanhong@gmail.com").read_text( + encoding="utf-8" + ).strip().endswith("Roger--Han") + + def test_add_strips_at_prefix(emails_dir): assert add_contributor("z@z.com", "@zeta") == 0 assert read_mapping_file(emails_dir / "z@z.com") == "zeta"