feat: change minor pattern to support optional conventional commit scopes

The Conventional Commits spec allows optional scopes to be present after the change type, e.g. `feat(scope):`. The current minor pattern will only bump the minor version number if the pattern exactly matches `feat:`. This change is backwards compatible and adds support for these scopes.
This commit is contained in:
Dom Light 2026-01-23 09:21:26 +00:00 committed by GitHub
parent 7bf8143b3b
commit 67c95513f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 21 additions and 7 deletions

View file

@ -13,7 +13,7 @@ export class ActionConfig {
/** A string which indicates the flags used by the `majorPattern` regular expression. */
public majorFlags: string = "";
/** A string which, if present in a git commit, indicates that a change represents a minor (feature) change. Wrap with '/' to match using a regular expression. */
public minorPattern: string = "/feat:/";
public minorPattern: string = "/^feat(\(.+\))?:/";
/** A string which indicates the flags used by the `minorPattern` regular expression. */
public minorFlags: string = "";
/** Pattern to use when formatting output version */

View file

@ -33,7 +33,7 @@ program
.option(
"-m, --minor-pattern <pattern>",
"Regex pattern for minor version bumps",
"/feat:/",
"/^feat(\(.+\))?:/",
)
.option("--minor-flags <flags>", "Flags for minor pattern regex", "")
.option(

View file

@ -217,6 +217,20 @@ testInterfaces.forEach((testInterface) => {
timeout,
);
test(
"Minor commits with conventional commit scopes bump minor version",
async () => {
const repo = createTestRepo(testRunner); // 0.0.0+0
repo.makeCommit("Initial Commit"); // 0.0.1+0
repo.makeCommit("feat(scope): Second Commit"); // 0.1.0+0
const result = await repo.runAction();
expect(result.formattedVersion).toBe("0.1.0+0");
},
timeout,
);
test(
"Tags start new version",
async () => {