feat: add ability to mark commit as breaking

Signed-off-by: Ardalan Amini <[email protected]>
This commit is contained in:
Ardalan Amini committed 2023-04-30 01:42:09 +03:30
1 parent 4b435e24d8
commit f676806e7f
4 files changed
+28 -8

No files matched your search

+21 -3
View File
@@ -23,8 +23,26 @@
*
*/
const REGEX = /^(?<type>[^:()]*)(?:\((?<scope>[^()]*?)\)|): *(?<description>.+?) *(?:\(#(?<pr>[1-9]\d*?)\)|) *(?:\[(?<flag>[^[\]]*?)]|)\s*$/;
const REGEX = /^(?<type>[^!:()]*)(?:\((?<scope>[^!()]*?)\)|)(?<breaking>!?): *(?<description>.+?) *(?:\(#(?<pr>[1-9]\d*?)\)|) *(?:\[(?<flag>[^[\]]*?)]|)\s*$/;
export function parseCommitMessage(message: string): { description?: string; flag?: string; pr?: `${ number }`; scope?: string; type?: string } {
return REGEX.exec(message)?.groups ?? {};
export function parseCommitMessage(message: string): ParsedCommitMessageI {
const { description, flag, pr, scope, type, breaking } = REGEX.exec(message)?.groups ?? {};
return {
breaking: !!breaking,
description,
flag,
pr,
scope,
type,
};
}
export interface ParsedCommitMessageI {
breaking: boolean;
description?: string;
flag?: string;
pr?: string;
scope?: string;
type?: string;
}