mirror of
https://github.com/PaulHatch/semantic-version.git
synced 2025-12-27 13:08:17 +00:00
Support namespaces without tags.
This commit is contained in:
parent
3a712b126c
commit
ae4e812946
5 changed files with 42 additions and 37 deletions
19
dist/index.js
vendored
19
dist/index.js
vendored
|
|
@ -264,18 +264,13 @@ class DefaultTagFormatter {
|
|||
return `${this.tagPrefix}*[0-9].*[0-9].*[0-9]`;
|
||||
}
|
||||
Parse(tag) {
|
||||
let stripedTag;
|
||||
if (this.tagPrefix.includes('/') && tag.includes(this.tagPrefix)) {
|
||||
let tagParts = tag
|
||||
.replace(this.tagPrefix, '<--!PREFIX!-->')
|
||||
.split('/');
|
||||
stripedTag = tagParts[tagParts.length - 1]
|
||||
.replace('<--!PREFIX!-->', this.tagPrefix);
|
||||
}
|
||||
else {
|
||||
let tagParts = tag.split('/');
|
||||
stripedTag = tagParts[tagParts.length - 1];
|
||||
}
|
||||
let tagParts = tag
|
||||
.replace(this.tagPrefix, '<--!PREFIX!-->')
|
||||
.replace(this.namespace, '<--!NAMESPACE!-->')
|
||||
.split('/');
|
||||
const stripedTag = tagParts[tagParts.length - 1]
|
||||
.replace('<--!PREFIX!-->', this.tagPrefix)
|
||||
.replace('<--!NAMESPACE!-->', this.namespace);
|
||||
let versionValues = stripedTag
|
||||
.substring(this.tagPrefix.length)
|
||||
.slice(0, this.namespace === '' ? 999 : -(this.namespace.length + 1))
|
||||
|
|
|
|||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -22,18 +22,13 @@ class DefaultTagFormatter {
|
|||
return `${this.tagPrefix}*[0-9].*[0-9].*[0-9]`;
|
||||
}
|
||||
Parse(tag) {
|
||||
let stripedTag;
|
||||
if (this.tagPrefix.includes('/') && tag.includes(this.tagPrefix)) {
|
||||
let tagParts = tag
|
||||
.replace(this.tagPrefix, '<--!PREFIX!-->')
|
||||
.split('/');
|
||||
stripedTag = tagParts[tagParts.length - 1]
|
||||
.replace('<--!PREFIX!-->', this.tagPrefix);
|
||||
}
|
||||
else {
|
||||
let tagParts = tag.split('/');
|
||||
stripedTag = tagParts[tagParts.length - 1];
|
||||
}
|
||||
let tagParts = tag
|
||||
.replace(this.tagPrefix, '<--!PREFIX!-->')
|
||||
.replace(this.namespace, '<--!NAMESPACE!-->')
|
||||
.split('/');
|
||||
const stripedTag = tagParts[tagParts.length - 1]
|
||||
.replace('<--!PREFIX!-->', this.tagPrefix)
|
||||
.replace('<--!NAMESPACE!-->', this.namespace);
|
||||
let versionValues = stripedTag
|
||||
.substring(this.tagPrefix.length)
|
||||
.slice(0, this.namespace === '' ? 999 : -(this.namespace.length + 1))
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export class DefaultTagFormatter implements TagFormatter {
|
|||
this.namespace = config.namespace;
|
||||
this.tagPrefix = config.tagPrefix;
|
||||
this.namespaceSeperator = '-'; // maybe make configurable in the future
|
||||
}
|
||||
}
|
||||
|
||||
public Format(versionInfo: VersionInformation): string {
|
||||
const result = `${this.tagPrefix}${versionInfo.major}.${versionInfo.minor}.${versionInfo.patch}`;
|
||||
|
|
@ -35,17 +35,16 @@ export class DefaultTagFormatter implements TagFormatter {
|
|||
}
|
||||
|
||||
public Parse(tag: string): [major: number, minor: number, patch: number] {
|
||||
let stripedTag;
|
||||
if (this.tagPrefix.includes('/') && tag.includes(this.tagPrefix)) {
|
||||
let tagParts = tag
|
||||
.replace(this.tagPrefix, '<--!PREFIX!-->')
|
||||
.split('/');
|
||||
stripedTag = tagParts[tagParts.length - 1]
|
||||
.replace('<--!PREFIX!-->', this.tagPrefix);
|
||||
} else {
|
||||
let tagParts = tag.split('/');
|
||||
stripedTag = tagParts[tagParts.length - 1];
|
||||
}
|
||||
|
||||
let tagParts = tag
|
||||
.replace(this.tagPrefix, '<--!PREFIX!-->')
|
||||
.replace(this.namespace, '<--!NAMESPACE!-->')
|
||||
.split('/');
|
||||
|
||||
const stripedTag = tagParts[tagParts.length - 1]
|
||||
.replace('<--!PREFIX!-->', this.tagPrefix)
|
||||
.replace('<--!NAMESPACE!-->', this.namespace);
|
||||
|
||||
let versionValues = stripedTag
|
||||
.substring(this.tagPrefix.length)
|
||||
.slice(0, this.namespace === '' ? 999 : -(this.namespace.length + 1))
|
||||
|
|
|
|||
|
|
@ -354,6 +354,22 @@ test('Namespace is tracked separately', async () => {
|
|||
expect(subprojectResult.formattedVersion).toBe('0.1.1+0');
|
||||
}, 15000);
|
||||
|
||||
test('Namespace allows dashes', async () => {
|
||||
const repo = createTestRepo({ tagPrefix: '' }); // 0.0.0
|
||||
|
||||
repo.makeCommit('Initial Commit'); // 0.0.1
|
||||
repo.exec('git tag 0.0.1');
|
||||
repo.makeCommit('Second Commit'); // 0.0.2
|
||||
repo.exec('git tag "0.1.0-sub/project"');
|
||||
repo.makeCommit('Third Commit'); // 0.0.2 / 0.1.1
|
||||
|
||||
const result = await repo.runAction();
|
||||
const subprojectResult = await repo.runAction({ namespace: "sub/project" });
|
||||
|
||||
expect(result.formattedVersion).toBe('0.0.2+1');
|
||||
expect(subprojectResult.formattedVersion).toBe('0.1.1+0');
|
||||
}, 15000);
|
||||
|
||||
test('Commits outside of path are not counted', async () => {
|
||||
const repo = createTestRepo({ tagPrefix: '' }); // 0.0.0
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue