mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-02 14:38:47 +00:00
feat: add ability to mark commit as breaking
Signed-off-by: Ardalan Amini <[email protected]>
This commit is contained in:
4 files changed
+28
-8
No files matched your search
+5
-3
@@ -48,6 +48,7 @@ interface ScopeGroupI {
|
||||
}
|
||||
|
||||
interface LogI {
|
||||
breaking: boolean;
|
||||
description: string;
|
||||
references: string[];
|
||||
}
|
||||
@@ -97,7 +98,7 @@ export async function generateChangelog(lastSha?: string): Promise<string> {
|
||||
|
||||
debug(`commit message -> ${ message }`);
|
||||
|
||||
let { type, scope, description, pr, flag } = parseCommitMessage(message);
|
||||
let { type, scope, description, pr, flag, breaking } = parseCommitMessage(message);
|
||||
|
||||
if (!description) continue;
|
||||
|
||||
@@ -138,6 +139,7 @@ export async function generateChangelog(lastSha?: string): Promise<string> {
|
||||
|
||||
if (log == null) {
|
||||
log = {
|
||||
breaking,
|
||||
description,
|
||||
references: [],
|
||||
};
|
||||
@@ -179,8 +181,8 @@ export async function generateChangelog(lastSha?: string): Promise<string> {
|
||||
prefix = " ";
|
||||
}
|
||||
|
||||
for (const { description, references } of logs) {
|
||||
let line = `${ prefix }* ${ description }`;
|
||||
for (const { breaking, description, references } of logs) {
|
||||
let line = `${ prefix }* ${ breaking ? "**breaking: **" : "" }${ description }`;
|
||||
|
||||
if (references.length > 0) line += ` (${ references.join(", ") })`;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user