Skip to content

The agent that grows with you

fix(scripts): accept legacy consecutive-hyphen GitHub logins in add_contributor

teknium14aab4c28d759
diff --git a/scripts/add_contributor.py b/scripts/add_contributor.py
index 8192fe4f55c..cb64b331cbb 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 3109a5e3143..655210aa989 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("[email protected]", "Roger--Han") == 0
+ assert (emails_dir / "[email protected]").read_text(
+ encoding="utf-8"
+ ).strip().endswith("Roger--Han")
+
+
def test_add_strips_at_prefix(emails_dir):
assert add_contributor("[email protected]", "@zeta") == 0
assert read_mapping_file(emails_dir / "[email protected]") == "zeta"