From aed2b93edc89e7113ac4349f64a334c92ebe77b0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bidegain Date: Wed, 18 Feb 2026 15:34:20 +0100 Subject: [PATCH] feat: allow # in scope --- conventional_pre_commit/format.py | 2 +- tests/test_format.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/conventional_pre_commit/format.py b/conventional_pre_commit/format.py index bb56001..6b664a8 100644 --- a/conventional_pre_commit/format.py +++ b/conventional_pre_commit/format.py @@ -126,7 +126,7 @@ def r_types(self): @property def r_scope(self): """Regex str for an optional (scope).""" - escaped_delimiters = list(map(re.escape, [":", ",", "-", "/", "."])) # type: ignore + escaped_delimiters = list(map(re.escape, [":", ",", "-", "/", ".", "#"])) # type: ignore if self.scopes: scopes = self._r_or(self.scopes) delimiters_pattern = self._r_or(escaped_delimiters) diff --git a/tests/test_format.py b/tests/test_format.py index 9bb8502..94ddbdf 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -444,6 +444,7 @@ def test_r_scope__special_chars(conventional_commit_scope_required): assert regex.match("(some:thing)") assert regex.match("(some,thing)") assert regex.match("(some.thing)") + assert regex.match("(some#thing)") def test_r_scope__scopes(conventional_commit_scope_required): @@ -649,6 +650,12 @@ def test_is_valid__with_scope(conventional_commit): assert conventional_commit.is_valid(input) +def test_is_valid__with_scope_and_hash(conventional_commit): + input = "feat(#scope): message" + + assert conventional_commit.is_valid(input) + + def test_is_valid__body_multiline_body_bad_type(conventional_commit): input = """wrong: message