From 6527c69359f611913e398e0b9bef8b1eba916594 Mon Sep 17 00:00:00 2001 From: Matthew Bryce Date: Wed, 23 Jul 2025 10:45:43 +0100 Subject: [PATCH] Added: test case for https://github.com/PaulHatch/semantic-version/issues/179 --- contributing.md | 4 ++-- src/main.test.ts | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/contributing.md b/contributing.md index fe5da64..2639a28 100644 --- a/contributing.md +++ b/contributing.md @@ -88,7 +88,7 @@ If you are not able to provide a test case, it is still very helpful to provide ## Forking the Project -If want to do something that does not fit with the project goals, particually if you want to include information from an outside system, it is probably best to fork the project and create your own action. One of the goals of this project starting in 5.0.0 is to be easy to fork and customize, and to that end the action has been broken into individual providers than can be replaced. All providers have been implemented using async calls specifically to support calls to external systems. +If want to do something that does not fit with the project goals, particularly if you want to include information from an outside system, it is probably best to fork the project and create your own action. One of the goals of this project starting in 5.0.0 is to be easy to fork and customize, and to that end the action has been broken into individual providers than can be replaced. All providers have been implemented using async calls specifically to support calls to external systems. The steps of this action are: @@ -98,7 +98,7 @@ The steps of this action are: - Classify the release Additionally a few formatter provide modular behavior to these step: -- A tag formmater is used to parse and format the version number +- A tag formatter is used to parse and format the version number - A version formatter is used to format output version string - A user formatter is used to format the user information in the output (JSON and CSV are provided in the default implementation) diff --git a/src/main.test.ts b/src/main.test.ts index b6f8950..0b5ddf8 100644 --- a/src/main.test.ts +++ b/src/main.test.ts @@ -1143,4 +1143,36 @@ test('Prerelease mode does not increment to 1.x.x', async () => { result = await repo.runAction(); expect(result.formattedVersion).toBe('1.1.0-prerelease.1'); expect(result.isTagged).toBe(true); -}, timeout); \ No newline at end of file +}, timeout); + +test('Versioning from branch always ignores major commit pattern', async () => { + const repo = createTestRepo({ + versionFromBranch: true, + majorPattern: "(MAJOR)" + }); + + repo.makeCommit('Initial Commit'); + repo.exec("git checkout -b release/v3.2"); + repo.makeCommit(`(MAJOR) Second Commit`); + + const result = await repo.runAction(); + + expect(result.formattedVersion).toBe('3.2.1+1'); + +}, timeout); + +test('Versioning from branch always ignores minor commit pattern', async () => { + const repo = createTestRepo({ + versionFromBranch: true, + minorPattern: "(MINOR)" + }); + + repo.makeCommit('Initial Commit'); + repo.exec("git checkout -b release/v3.2"); + repo.makeCommit(`(MINOR) Second Commit`); + + const result = await repo.runAction(); + + expect(result.formattedVersion).toBe('3.2.1+1'); + +}, timeout);