Skip to content

Commit

Permalink
Allow slashes in tag prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHatch committed Apr 23, 2021
1 parent 8e99275 commit 27c5676
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
15 changes: 12 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1099,9 +1099,18 @@ const setOutput = (major, minor, patch, increment, changed, branch, namespace) =

const parseVersion = (tag) => {

console.log(tag);
let tagParts = tag.split('/');
let versionValues = tagParts[tagParts.length - 1]
let stripedTag;
if (tagPrefix.includes('/') && tag.includes(tagPrefix)) {
let tagParts = tag
.replace(tagPrefix, '<--!PREFIX!-->')
.split('/');
stripedTag = tagParts[tagParts.length - 1]
.replace('<--!PREFIX!-->', tagPrefix);
} else {
let tagParts = tag.split('/');
stripedTag = tagParts[tagParts.length - 1];
}
let versionValues = stripedTag
.substr(tagPrefix.length)
.slice(0, namespace === '' ? 999 : -(namespace.length + 1))
.split('.');
Expand Down
15 changes: 12 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,18 @@ const setOutput = (major, minor, patch, increment, changed, branch, namespace) =

const parseVersion = (tag) => {

console.log(tag);
let tagParts = tag.split('/');
let versionValues = tagParts[tagParts.length - 1]
let stripedTag;
if (tagPrefix.includes('/') && tag.includes(tagPrefix)) {
let tagParts = tag
.replace(tagPrefix, '<--!PREFIX!-->')
.split('/');
stripedTag = tagParts[tagParts.length - 1]
.replace('<--!PREFIX!-->', tagPrefix);
} else {
let tagParts = tag.split('/');
stripedTag = tagParts[tagParts.length - 1];
}
let versionValues = stripedTag
.substr(tagPrefix.length)
.slice(0, namespace === '' ? 999 : -(namespace.length + 1))
.split('.');
Expand Down
12 changes: 12 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,5 +564,17 @@ test('Short tags disabled matches full tags', () => {

expect(result).toMatch('Version is 1.2.3+0');

repo.clean();
});

test('Tag prefix can include forward slash', () => {
const repo = createTestRepo({ short_tags: 'false', tag_prefix: 'version/' }); // 0.0.0

repo.makeCommit('Initial Commit');
repo.exec('git tag version/1.2.3');
const result = repo.runAction();

expect(result).toMatch('Version is 1.2.3+0');

repo.clean();
});

0 comments on commit 27c5676

Please sign in to comment.