Skip to content

Commit

Permalink
Fix "full tag" match pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHatch committed Feb 25, 2021
1 parent d061f3f commit ed818a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

0 comments on commit ed818a7

Please sign in to comment.