mirror of
https://github.com/PaulHatch/semantic-version.git
synced 2026-04-08 00:54:17 +00:00
Ignore non-version branches, reset diagnostics between tests
This commit is contained in:
parent
cfbfddabdd
commit
ec20cad99a
17 changed files with 2358 additions and 1307 deletions
|
|
@ -36,8 +36,8 @@ exports.cmd = void 0;
|
|||
// Using require instead of import to support integration testing
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const DebugManager_1 = require("./DebugManager");
|
||||
const debugManager = DebugManager_1.DebugManager.getInstance();
|
||||
const cmd = (command, ...args) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const debugManager = DebugManager_1.DebugManager.getInstance();
|
||||
if (debugManager.isReplayMode()) {
|
||||
return debugManager.replayCommand(command, args);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ class DebugManager {
|
|||
}
|
||||
return DebugManager.instance;
|
||||
}
|
||||
/** Clears the singleton instance of the DebugManager (used for testing) */
|
||||
static clearState() {
|
||||
DebugManager.instance = new DebugManager();
|
||||
}
|
||||
/** Returns true if debug mode is enabled */
|
||||
isDebugEnabled() {
|
||||
return this.debugEnabled;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,15 @@ class BranchVersioningTagFormatter extends DefaultTagFormatter_1.DefaultTagForma
|
|||
}
|
||||
constructor(config, branchName) {
|
||||
super(config);
|
||||
this.branchName = branchName;
|
||||
const pattern = config.versionFromBranch === true ?
|
||||
new RegExp("[0-9]+.[0-9]+$|[0-9]+$") :
|
||||
this.getRegex(config.versionFromBranch);
|
||||
const result = pattern.exec(branchName);
|
||||
if (result === null) {
|
||||
this.major = NaN;
|
||||
this.onVersionBranch = false;
|
||||
return;
|
||||
}
|
||||
let branchVersion;
|
||||
switch (result === null || result === void 0 ? void 0 : result.length) {
|
||||
case 1:
|
||||
|
|
@ -30,6 +34,7 @@ class BranchVersioningTagFormatter extends DefaultTagFormatter_1.DefaultTagForma
|
|||
default:
|
||||
throw new Error(`Unable to parse version from branch named '${branchName}' using pattern '${pattern}'`);
|
||||
}
|
||||
this.onVersionBranch = true;
|
||||
const versionValues = branchVersion.split('.');
|
||||
if (versionValues.length > 2) {
|
||||
throw new Error(`The version string '${branchVersion}' parsed from branch '${branchName}' is invalid. It must be in the format 'major.minor' or 'major'`);
|
||||
|
|
@ -45,7 +50,20 @@ class BranchVersioningTagFormatter extends DefaultTagFormatter_1.DefaultTagForma
|
|||
}
|
||||
}
|
||||
}
|
||||
GetPattern() {
|
||||
let pattern = super.GetPattern();
|
||||
if (!this.onVersionBranch) {
|
||||
return pattern;
|
||||
}
|
||||
if (this.minor === undefined) {
|
||||
return pattern.replace('*[0-9].*[0-9].*[0-9]', `${this.major}.*[0-9].*[0-9]`);
|
||||
}
|
||||
return pattern.replace('*[0-9].*[0-9].*[0-9]', `${this.major}.${this.minor}.*[0-9]`);
|
||||
}
|
||||
IsValid(tag) {
|
||||
if (!this.onVersionBranch) {
|
||||
return super.IsValid(tag);
|
||||
}
|
||||
if (!super.IsValid(tag)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -59,6 +77,9 @@ class BranchVersioningTagFormatter extends DefaultTagFormatter_1.DefaultTagForma
|
|||
return true;
|
||||
}
|
||||
Parse(tag) {
|
||||
if (!this.onVersionBranch) {
|
||||
return super.Parse(tag);
|
||||
}
|
||||
const parsed = super.Parse(tag);
|
||||
return [this.major, this.minor || parsed[1], parsed[2]];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,15 +39,12 @@ class BumpAlwaysVersionClassifier extends DefaultVersionClassifier_1.DefaultVers
|
|||
else if (this.minorPattern(commit)) {
|
||||
type = VersionType_1.VersionType.Minor;
|
||||
}
|
||||
else if (this.patchPattern(commit) ||
|
||||
(major === 0 && minor === 0 && patch === 0 && commitSet.commits.length > 0)) {
|
||||
type = VersionType_1.VersionType.Patch;
|
||||
}
|
||||
else {
|
||||
if (this.patchPattern(commit) ||
|
||||
(major === 0 && minor === 0 && patch === 0 && commitSet.commits.length > 0)) {
|
||||
type = VersionType_1.VersionType.Patch;
|
||||
}
|
||||
else {
|
||||
type = VersionType_1.VersionType.None;
|
||||
increment++;
|
||||
}
|
||||
type = VersionType_1.VersionType.None;
|
||||
}
|
||||
if (this.enablePrereleaseMode && major === 0) {
|
||||
switch (type) {
|
||||
|
|
@ -61,7 +58,9 @@ class BumpAlwaysVersionClassifier extends DefaultVersionClassifier_1.DefaultVers
|
|||
patch += 1;
|
||||
increment = 0;
|
||||
break;
|
||||
default: break;
|
||||
default:
|
||||
increment++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -80,7 +79,9 @@ class BumpAlwaysVersionClassifier extends DefaultVersionClassifier_1.DefaultVers
|
|||
patch += 1;
|
||||
increment = 0;
|
||||
break;
|
||||
default: break;
|
||||
default:
|
||||
increment++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class DefaultCurrentCommitResolver {
|
|||
ResolveBranchNameAsync() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const branchName = this.branch == 'HEAD' ?
|
||||
process.env.GITHUB_REF_NAME || (yield (0, CommandRunner_1.cmd)('git', 'rev-parse', '--abbrev-ref', 'HEAD'))
|
||||
process.env.GITHUB_REF_NAME || (yield (0, CommandRunner_1.cmd)('git', 'branch', '--show-current'))
|
||||
: this.branch;
|
||||
return branchName.trim();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ class DefaultVersionClassifier {
|
|||
// - commit 3 was tagged v2.0.0 - v2.0.0+0
|
||||
// - commit 4 - v2.0.1+0
|
||||
const versionsMatch = lastRelease.currentMajor === major && lastRelease.currentMinor === minor && lastRelease.currentPatch === patch;
|
||||
const currentIncremement = versionsMatch ? increment : 0;
|
||||
return new VersionClassification_1.VersionClassification(VersionType_1.VersionType.None, currentIncremement, false, lastRelease.currentMajor, lastRelease.currentMinor, lastRelease.currentPatch);
|
||||
const currentIncrement = versionsMatch ? increment : 0;
|
||||
return new VersionClassification_1.VersionClassification(VersionType_1.VersionType.None, currentIncrement, false, lastRelease.currentMajor, lastRelease.currentMinor, lastRelease.currentPatch);
|
||||
}
|
||||
return new VersionClassification_1.VersionClassification(type, increment, changed, major, minor, patch);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ var VersionType;
|
|||
VersionType["Patch"] = "Patch";
|
||||
/** Indicates no change--generally this means that the current commit is already tagged with a version */
|
||||
VersionType["None"] = "None";
|
||||
})(VersionType = exports.VersionType || (exports.VersionType = {}));
|
||||
})(VersionType || (exports.VersionType = VersionType = {}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue