fix: make v character in version tags optional (#423)

* fix: make v character in version tags optional

* fix: cross platform regex

* fix: test regex within grep.

* fix: add semantic tags prepended with v
This commit is contained in:
Webber Takken
2022-08-04 02:09:32 +02:00
committed by GitHub
parent c068855899
commit db2d8b6dbd
7 changed files with 165 additions and 16 deletions

15
dist/index.js generated vendored
View File

@@ -5921,6 +5921,9 @@ class Versioning {
static get strategies() {
return { None: 'None', Semantic: 'Semantic', Tag: 'Tag', Custom: 'Custom' };
}
static get grepCompatibleInputVersionRegex() {
return '^v?([0-9]+\\.)*[0-9]+.*';
}
/**
* Get the branch name of the (related) branch
*/
@@ -6158,17 +6161,19 @@ class Versioning {
});
}
/**
* Whether or not the repository has any version tags yet.
* Whether the current tree has any version tags yet.
*
* Note: Currently this is run in all OSes, so the syntax must be cross-platform.
*/
static hasAnyVersionTags() {
return __awaiter(this, void 0, void 0, function* () {
const numberOfCommitsAsString = yield system_1.default.run('sh', undefined, {
input: Buffer.from('git tag --list --merged HEAD | grep v[0-9]* | wc -l'),
const numberOfTagsAsString = yield system_1.default.run('sh', undefined, {
input: Buffer.from(`git tag --list --merged HEAD | grep -E '${this.grepCompatibleInputVersionRegex}' | wc -l`),
cwd: this.projectPath,
silent: false,
});
const numberOfCommits = Number.parseInt(numberOfCommitsAsString, 10);
return numberOfCommits !== 0;
const numberOfTags = Number.parseInt(numberOfTagsAsString, 10);
return numberOfTags !== 0;
});
}
/**

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long