Commit c5a1264
fix: allow category extraction when scope is used (#240)
This PR changes the category extraction to use a RegExp to matches
[**Conventional Commits** that start with `feat:` or `fix:` (optionally
with a scope like
`feat(scope):`)](https://www.conventionalcommits.org/en/v1.0.0/#:~:text=A%20scope%20may%20be%20provided%20to%20a%20commit%E2%80%99s%20type%2C%20to%20provide%20additional%20contextual%20information%20and%20is%20contained%20within%20parenthesis%2C%20e.g.%2C%20feat(parser)%3A%20add%20ability%20to%20parse%20arrays.).
- adds tests for getCategory to make sure all previous behaviours are
preserved and new one works.
- exports getCategory to make it testable.
- updates getCategory to use regex to extract known category even when
scope is present.
### Regex breakdown
- `^` – Start of the string
- `(feat|fix)` – Must start with either `feat` or `fix`
- `(?:\([^)]*\))?` – Optionally match a scope in parentheses like
`(bridge)` or `(ramps)`
- `\s*:\s*` – Requires a colon `:` (with optional spaces before/after)
- `/u` – Unicode flag (as GitHub allows PR titles to contain unicode)
See https://consensys.slack.com/archives/C08N7NQRBPU/p1745578034343929
---------
Co-authored-by: Jongsun Suh <[email protected]>1 parent 308220b commit c5a1264
2 files changed
+52
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
220 | 222 | | |
221 | 223 | | |
222 | 224 | | |
| |||
0 commit comments