Exclude pre-release tags from version consideration

This commit is contained in:
Paul Hatcherian 2022-12-17 19:56:43 -06:00
parent ba6e71e658
commit 02763ed6d3
8 changed files with 74 additions and 10 deletions

View file

@ -42,5 +42,11 @@ class DefaultTagFormatter {
return [major, minor, patch];
}
;
IsValid(tag) {
if (!!this.namespace) {
return new RegExp(`^${this.tagPrefix}[0-9]+.[0-9]+.[0-9]+${this.namespaceSeperator}${this.namespace}$`).test(tag);
}
return new RegExp(`^${this.tagPrefix}[0-9]+.[0-9]+.[0-9]+$`).test(tag);
}
}
exports.DefaultTagFormatter = DefaultTagFormatter;

View file

@ -54,11 +54,17 @@ class DefaultLastReleaseResolver {
// so that we will have an accurate increment (assuming the new tag is the expected one)
const command = `git for-each-ref --count=2 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
tag = yield (0, CommandRunner_1.cmd)(command);
tag = tag.split('\n').reverse().find(t => t !== '' && t !== currentTag) || '';
tag = tag
.split('\n')
.reverse()
.find(t => tagFormatter.IsValid(t) && t !== currentTag) || '';
}
else {
const command = `git for-each-ref --count=1 --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
tag = yield (0, CommandRunner_1.cmd)(command);
const command = `git for-each-ref --sort=-v:*refname --format=%(refname:short) --merged=${current} ${refPrefixPattern}${releasePattern}`;
let tags = yield (0, CommandRunner_1.cmd)(command);
tag = tags
.split('\n')
.find(t => tagFormatter.IsValid(t)) || '';
}
tag = tag.trim();
}