mirror of
https://github.com/PaulHatch/semantic-version.git
synced 2025-12-27 04:58:17 +00:00
Allow slashes in tag prefix
This commit is contained in:
parent
8e99275875
commit
27c5676700
3 changed files with 36 additions and 6 deletions
15
dist/index.js
vendored
15
dist/index.js
vendored
|
|
@ -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('.');
|
||||
|
|
|
|||
15
index.js
15
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('.');
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
Loading…
Reference in a new issue