From ed818a75eb51eee5b4072b72a07031cd52a9f09f Mon Sep 17 00:00:00 2001 From: Paul Hatcherian <1835615+PaulHatch@users.noreply.github.com> Date: Thu, 25 Feb 2021 08:51:40 -0500 Subject: [PATCH] Fix "full tag" match pattern --- dist/index.js | 2 +- index.js | 2 +- index.test.js | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index b2acdaf..9d0ea53 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1139,7 +1139,7 @@ async function run() { branch = (await cmd('git', 'rev-parse', 'HEAD')).trim(); } - const versionPattern = shortTags ? '*[0-9.]' : '[0-9]+\\.[0-9]+\\.[0-9]+' + const versionPattern = shortTags ? '*[0-9.]' : '*[0-9].*[0-9].*[0-9]' const releasePattern = namespace === '' ? `${tagPrefix}${versionPattern}` : `${tagPrefix}${versionPattern}-${namespace}`; let major = 0, minor = 0, patch = 0, increment = 0; let changed = true; diff --git a/index.js b/index.js index 16489d2..8d81c43 100644 --- a/index.js +++ b/index.js @@ -118,7 +118,7 @@ async function run() { branch = (await cmd('git', 'rev-parse', 'HEAD')).trim(); } - const versionPattern = shortTags ? '*[0-9.]' : '[0-9]+\\.[0-9]+\\.[0-9]+' + const versionPattern = shortTags ? '*[0-9.]' : '*[0-9].*[0-9].*[0-9]' const releasePattern = namespace === '' ? `${tagPrefix}${versionPattern}` : `${tagPrefix}${versionPattern}-${namespace}`; let major = 0, minor = 0, patch = 0, increment = 0; let changed = true; diff --git a/index.test.js b/index.test.js index 55d7371..3caa8ed 100644 --- a/index.test.js +++ b/index.test.js @@ -549,5 +549,20 @@ test('Regular expressions can be used as minor tag', () => { repo.makeCommit('Second Commit SomeValue'); // 0.0.1+1 expect(repo.runAction()).toMatch('Version is 0.1.0+0'); + repo.clean(); +}); + +test('Short tags disabled matches full tags', () => { + const repo = createTestRepo({ short_tags: 'false' }); // 0.0.0 + + repo.makeCommit('Initial Commit'); + repo.makeCommit('Second Commit'); + repo.makeCommit('Third Commit'); + repo.exec('git tag v1.2.3'); + + const result = repo.runAction(); + + expect(result).toMatch('Version is 1.2.3+0'); + repo.clean(); }); \ No newline at end of file