Skip to content

Commit 21f68c9

Browse files
committed
🔧 fix(regex): update headerPattern to match non-word characters in commit messages
1 parent 941826e commit 21f68c9

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎.releaserc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{ "type": "chore", "release": "patch", "subject": "/^([\u231A-\uD83E\uDDFF]|:[^:]+:)/" }
2323
],
2424
"parserOpts": {
25-
"headerPattern": "^(?:([\u231A-\uD83E\uDDFF]|:[^:]+:)?\\s*)?([\\w-]+)(?:\\(([^)]+)\\))?:?\\s(.+)$"
25+
"headerPattern": "^(?:[\\W_]+)?([\\w-]+)(?:\\(([^)]+)\\))?:?\\s(.+)$"
2626
}
2727
}
2828
],

‎test_commit_regex.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import re
2+
3+
# Simpler regex to match any non-word character (emoji or symbol) at the start
4+
pattern = r"^(?:[\W_]+)?([\w-]+)(?:\(([^)]+)\))?:?\s(.+)$"
5+
6+
commit = "🔧 fix(workflows): correct condition for running tests in setup-and-test action"
7+
8+
match = re.match(pattern, commit)
9+
if match:
10+
print("type:", match.group(1))
11+
print("scope:", match.group(2))
12+
print("subject:", match.group(3))
13+
else:
14+
print("No match")

0 commit comments

Comments
 (0)