| 242 | } |
| 243 | |
| 244 | export function parseCommit(commit: RawCommit): ParsedCommit { |
| 245 | const prNumber = extractPrNumber(commit.subject); |
| 246 | const subjectWithoutPr = commit.subject.replace(/\s+\(#\d+\)$/, ""); |
| 247 | const parsedSubject = parseConventionalSubject(subjectWithoutPr); |
| 248 | const category = categorizeCommit(parsedSubject); |
| 249 | |
| 250 | return { |
| 251 | ...commit, |
| 252 | ...parsedSubject, |
| 253 | category, |
| 254 | prNumber, |
| 255 | }; |
| 256 | } |
| 257 | |
| 258 | export function parseConventionalSubject(subject: string): ParsedSubject { |
| 259 | const match = /^([a-z]+)(?:\(([^)]+)\))?(!)?:\s+(.+)$/.exec(subject); |