diff --git a/dist/index.js b/dist/index.js index 9d0ea53..4ee5dd5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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('.'); diff --git a/index.js b/index.js index 8d81c43..79548a6 100644 --- a/index.js +++ b/index.js @@ -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('.'); diff --git a/index.test.js b/index.test.js index 3caa8ed..4bf95fb 100644 --- a/index.test.js +++ b/index.test.js @@ -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(); }); \ No newline at end of file