- recompile index.js after changes from previous PR

This commit is contained in:
Mike Penz
2020-10-20 12:17:10 +02:00
parent f1aecb862c
commit e72e554cca
2 changed files with 40 additions and 7 deletions
Generated Vendored
+39 -6
View File
@@ -140,7 +140,11 @@ exports.DefaultConfiguration = {
labels: ['test'] labels: ['test']
} }
], ],
transformers: [] // transformers to apply on the PR description according to the `pr_template` transformers: [],
tag_resolver: {
// defines the logic on how to resolve the previous tag, only relevant if `fromTag` is not specified
method: 'semver' // defines which method to use, by default it will use `semver` (dropping all non matching tags). Alternative `sort` is also available.
}
}; };
@@ -773,7 +777,7 @@ class ReleaseNotesBuilder {
core.debug(`fromTag undefined, trying to resolve via API`); core.debug(`fromTag undefined, trying to resolve via API`);
const tagsApi = new tags_1.Tags(octokit); const tagsApi = new tags_1.Tags(octokit);
const previousTag = yield tagsApi.findPredecessorTag(this.owner, this.repo, this.toTag, this.ignorePreReleases, this.configuration.max_tags_to_fetch || const previousTag = yield tagsApi.findPredecessorTag(this.owner, this.repo, this.toTag, this.ignorePreReleases, this.configuration.max_tags_to_fetch ||
configuration_1.DefaultConfiguration.max_tags_to_fetch); configuration_1.DefaultConfiguration.max_tags_to_fetch, this.configuration.tag_resolver || configuration_1.DefaultConfiguration.tag_resolver);
if (previousTag == null) { if (previousTag == null) {
utils_1.failOrError(`💥 Unable to retrieve previous tag given ${this.toTag}`, this.failOnError); utils_1.failOrError(`💥 Unable to retrieve previous tag given ${this.toTag}`, this.failOnError);
return null; return null;
@@ -888,9 +892,9 @@ class Tags {
return tagsInfo; return tagsInfo;
}); });
} }
findPredecessorTag(owner, repo, tag, ignorePreReleases, maxTagsToFetch) { findPredecessorTag(owner, repo, tag, ignorePreReleases, maxTagsToFetch, tagResolver) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const tags = sortTags(yield this.getTags(owner, repo, maxTagsToFetch)); const tags = sortTags(yield this.getTags(owner, repo, maxTagsToFetch), tagResolver);
try { try {
const length = tags.length; const length = tags.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
@@ -929,7 +933,16 @@ exports.Tags = Tags;
2020.3.1-a01 2020.3.1-a01
2020.3.0 2020.3.0
*/ */
function sortTags(tags) { function sortTags(tags, tagResolver) {
if (tagResolver.method === 'sort') {
return stringSorting(tags);
}
else {
return semVerSorting(tags);
}
}
exports.sortTags = sortTags;
function semVerSorting(tags) {
// filter out tags which do not follow semver // filter out tags which do not follow semver
const validatedTags = tags.filter(tag => { const validatedTags = tags.filter(tag => {
const isValid = semver.valid(tag.name) !== null; const isValid = semver.valid(tag.name) !== null;
@@ -944,7 +957,27 @@ function sortTags(tags) {
}); });
return validatedTags; return validatedTags;
} }
exports.sortTags = sortTags; function stringSorting(tags) {
return tags.sort((b, a) => {
const partsA = a.name.replace(/^v/, '').split('-');
const partsB = b.name.replace(/^v/, '').split('-');
const versionCompare = partsA[0].localeCompare(partsB[0]);
if (versionCompare !== 0) {
return versionCompare;
}
else {
if (partsA.length === 1) {
return 0;
}
else if (partsB.length === 1) {
return 1;
}
else {
return partsA[1].localeCompare(partsB[1]);
}
}
});
}
/***/ }), /***/ }),
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long