Skip to content

Commit

Permalink
✨add extract-emoji's docstring (#2)
Browse files Browse the repository at this point in the history
* add extract-emoji's docstring

* update

* remove pdb
  • Loading branch information
lucemia authored Jun 14, 2024
1 parent bce3801 commit e6659fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Commitlint PR Title

on:
pull_request:
types: [opened, edited, labeled, unlabeled]
types: [opened, labeled, unlabeled]

jobs:
commitlint:
Expand Down
12 changes: 11 additions & 1 deletion src/pr_lint/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@
"\U0001F1E0-\U0001F1FF" # Flags (iOS)
"\U0001F900-\U0001F9FF" # Supplemental Symbols and Pictographs
"\U0001FA70-\U0001FAFF" # Symbols and Pictographs Extended-A
"\u2600-\u26FF" # Miscellaneous Symbols
"\u2700-\u27BF" # Dingbats
"]+"
)

app = typer.Typer()


def extract_emoji(string: str) -> set[str]:
"""
Extracts emojis from a string
Args:
string: The string to extract emojis from
Returns:
A set of emojis
"""
return set(emoji_pattern.findall(string))


Expand Down Expand Up @@ -68,7 +79,6 @@ def main() -> None:
assert len(type_labels) == 1, "There should be exactly one Type label"

# format new title as [Type Emoji][Title][Other Emojis]

type_emoji = "".join(extract_emoji(type_labels[0].name))
other_emojis = set()
for label in other_labels:
Expand Down
1 change: 1 addition & 0 deletions src/pr_lint/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def test_clean_title(title: str, snapshot: SnapshotAssertion) -> None:
[
("🐛fix: correct typo🐛", {"🐛"}),
("🚀feature(add-new): add a new feature🚀", {"🚀"}),
("✨Type: Feature", {"✨"}),
("bug: fix issue 🐞", {"🐞"}),
("no type", set()),
("not an emoji prefix: but contains 🚀 emoji", {"🚀"}),
Expand Down

0 comments on commit e6659fb

Please sign in to comment.