Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions scripts/devstream/description.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"(?<![^\W\d_])#")
EMOJI = re.compile("[\U0001f000-\U0001faff\u2600-\u27bf]")
VARIATION = re.compile("[\ufe00-\ufe0f]")
ZWJ = "\u200d"
Expand Down Expand Up @@ -114,8 +116,8 @@ def clean_description(text: str) -> 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()):
Expand Down
5 changes: 5 additions & 0 deletions scripts/tests/test_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading