Add debug/replay mode (MINOR)

This commit is contained in:
Paul Hatcherian 2023-08-20 21:33:26 -04:00
parent 4f07cfb9e0
commit d93d2fb887
20 changed files with 480 additions and 56 deletions

View file

@ -16,7 +16,9 @@ const VersionType_1 = require("./VersionType");
class BumpAlwaysVersionClassifier extends DefaultVersionClassifier_1.DefaultVersionClassifier {
constructor(config) {
super(config);
// Placeholder for consistency
this.patchPattern = !config.bumpEachCommitPatchPattern ?
_ => true :
this.parsePattern(config.bumpEachCommitPatchPattern, "", config.searchCommitBody);
}
ClassifyAsync(lastRelease, commitSet) {
return __awaiter(this, void 0, void 0, function* () {
@ -25,6 +27,7 @@ class BumpAlwaysVersionClassifier extends DefaultVersionClassifier_1.DefaultVers
}
let { major, minor, patch } = lastRelease;
let type = VersionType_1.VersionType.None;
let increment = 0;
if (commitSet.commits.length === 0) {
return new VersionClassification_1.VersionClassification(type, 0, false, major, minor, patch);
}
@ -34,18 +37,28 @@ class BumpAlwaysVersionClassifier extends DefaultVersionClassifier_1.DefaultVers
minor = 0;
patch = 0;
type = VersionType_1.VersionType.Major;
increment = 0;
}
else if (this.minorPattern(commit)) {
minor += 1;
patch = 0;
type = VersionType_1.VersionType.Minor;
increment = 0;
}
else {
patch += 1;
type = VersionType_1.VersionType.Patch;
if (this.patchPattern(commit) ||
(major === 0 && minor === 0 && patch === 0 && commitSet.commits.length > 0)) {
patch += 1;
type = VersionType_1.VersionType.Patch;
increment = 0;
}
else {
type = VersionType_1.VersionType.None;
increment++;
}
}
}
return new VersionClassification_1.VersionClassification(type, 0, true, major, minor, patch);
return new VersionClassification_1.VersionClassification(type, increment, true, major, minor, patch);
});
}
}

View file

@ -20,8 +20,10 @@ class DefaultVersionClassifier {
this.enablePrereleaseMode = config.enablePrereleaseMode;
}
parsePattern(pattern, flags, searchBody) {
if (pattern.startsWith('/') && pattern.endsWith('/')) {
var regex = new RegExp(pattern.slice(1, -1), flags);
if (/^\/.+\/[i]*$/.test(pattern)) {
const regexEnd = pattern.lastIndexOf('/');
const parsedFlags = pattern.slice(pattern.lastIndexOf('/') + 1);
const regex = new RegExp(pattern.slice(1, regexEnd), parsedFlags || flags);
return searchBody ?
(commit) => regex.test(commit.subject) || regex.test(commit.body) :
(commit) => regex.test(commit.subject);