Parse a commit subject into conventional commit format
(commit: { hash: string; subject: string; body: string })
| 229 | } |
| 230 | return commits; |
| 231 | } |
| 232 | |
| 233 | /** Parse a commit subject into conventional commit format */ |
| 234 | function parseConventionalCommit(commit: { hash: string; subject: string; body: string }): ConventionalCommit | null { |
| 235 | // Match: type(scope)!: description OR type!(scope): description OR type!: description |
| 236 | const match = commit.subject.match(/^(\w+)(!)?(?:\(([^)]+)\))?(!)?\s*:\s*(.+)$/); |
| 237 | if (!match) return null; |
| 238 | |
| 239 | const [, type, bang1, scope, bang2, description] = match; |
| 240 | const breaking = !!bang1 || !!bang2 || commit.body.includes('BREAKING CHANGE'); |
| 241 | |
| 242 | return { |
| 243 | hash: commit.hash, |
| 244 | type: type!.toLowerCase(), |
| 245 | scope: scope || null, |
| 246 | breaking, |
| 247 | description: description!.trim(), |
| 248 | body: commit.body, |
| 249 | }; |
| 250 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…