diff --git a/README.md b/README.md index a37ef0a..61ed291 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,19 @@ refactor(*): clean up The above commit causes `patch` upgrade to the all packages. +## Unstable updates + +You can mark the change only affects the unstable part of the package by using +`scope/unstable` or `unstable/scope`. + +``` +feat(crypto/unstable): a new unstable feature +BREAKING(crypto/unstable): breaking change to unstable feature +``` + +If this notation is used, the effect of the commit becomes `patch` no matter +what commit type is used. + # License MIT diff --git a/util.ts b/util.ts index 25660dd..3c46fd6 100644 --- a/util.ts +++ b/util.ts @@ -88,6 +88,7 @@ export type VersionUpdateResult = { }; const RE_DEFAULT_PATTERN = /^([^:()]+)(?:\((.+)\))?: (.*)$/; +const REGEXP_UNSTABLE_SCOPE = /^(unstable\/(.+)|(.+)\/unstable)$/; // Defines the version bump for each tag. const TAG_TO_VERSION: Record = { @@ -153,7 +154,20 @@ export function defaultParseCommitMessage( reason: `Unknown commit tag: ${tag}.`, }; } - return modules.map((module) => ({ module, tag, version, commit })); + return modules.map((module) => { + const matchUnstable = REGEXP_UNSTABLE_SCOPE.exec(module); + if (matchUnstable) { + // 'scope' is in the form of unstable/foo or foo/unstable + // In this case all changes are considered as patch + return { + module: matchUnstable[2] || matchUnstable[3], + tag, + commit, + version: "patch", + }; + } + return ({ module, tag, version, commit }); + }); } export function summarizeVersionBumpsByModule( diff --git a/util_test.ts b/util_test.ts index 303494a..12472fd 100644 --- a/util_test.ts +++ b/util_test.ts @@ -205,6 +205,35 @@ Deno.test("defaultParseCommitMessage()", () => { }, }, ]); + + assertEquals(parse("feat(foo/unstable): a new unstable feature", modules), [ + { + module: "foo", + tag: "feat", + version: "patch", + commit: { + subject: "feat(foo/unstable): a new unstable feature", + body: "", + hash, + }, + }, + ]); + + assertEquals( + parse("BREAKING(unstable/foo): break some unstable feature", modules), + [ + { + module: "foo", + tag: "BREAKING", + version: "patch", + commit: { + subject: "BREAKING(unstable/foo): break some unstable feature", + body: "", + hash, + }, + }, + ], + ); }); Deno.test("checkModuleName()", () => {