diff --git a/scripts/devstream/description.py b/scripts/devstream/description.py index f2c3407..c9aec1b 100644 --- a/scripts/devstream/description.py +++ b/scripts/devstream/description.py @@ -3,7 +3,9 @@ from pathlib import Path MIN_LEN, MAX_LEN = 10, 140 -FORBIDDEN = set("<>[]()`*_#") +FORBIDDEN = set("<>[]()`*_") +# Only "#" straight after a letter is a name like C# or F#; anywhere else it is a heading or an issue link. +HASH = re.compile(r"(? tuple[str | None, str | None]: return None, "Descriptions can't include links." if "@" in t: return None, "Descriptions can't mention people or teams." - if FORBIDDEN & set(t): - return None, "Descriptions can't include these characters: < > [ ] ( ) ` * _ #" + if FORBIDDEN & set(t) or HASH.search(t): + return None, "Descriptions can't include < > [ ] ( ) ` * or _, and # only in a name like C#." if any(w.isupper() and len(w) > 5 for w in re.findall(r"[^\W\d_]+", t)): return None, "Descriptions can't have long words in ALL CAPS." if BLOCKED.search(t.casefold()): diff --git a/scripts/tests/test_description.py b/scripts/tests/test_description.py index 19d0bf4..ac4a3cf 100644 --- a/scripts/tests/test_description.py +++ b/scripts/tests/test_description.py @@ -82,6 +82,11 @@ def test_forbidden_characters(self): for c in "<>[]()`*_#": bad(f"A tool with a {c} in the text here") + def test_hash_only_after_a_letter(self): + ok("A fast JSON parser for C# and F# projects") + for t in ("Fixes #123 and more in the tool", "A tool ## for headings here", "Ranked 1# among all the tools", "A tool for C_# and the rest"): + bad(t) + def test_emoji_runs(self): ok("A neat tool \U0001F600\U0001F600 for people") bad("A neat tool \U0001F600\U0001F600\U0001F600 for people")