Ignore non-version branches, reset diagnostics between tests

This commit is contained in:
Paul Hatcherian 2023-09-30 04:51:49 -04:00
parent cfbfddabdd
commit ec20cad99a
17 changed files with 2358 additions and 1307 deletions

156
dist/index.js vendored
View file

@ -43,8 +43,8 @@ exports.cmd = void 0;
// Using require instead of import to support integration testing
const exec = __importStar(__nccwpck_require__(1514));
const DebugManager_1 = __nccwpck_require__(1823);
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);
}
@ -147,6 +147,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;
@ -361,11 +365,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:
@ -377,6 +385,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'`);
@ -392,7 +401,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;
}
@ -406,6 +428,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]];
}
@ -721,15 +746,12 @@ class BumpAlwaysVersionClassifier extends DefaultVersionClassifier_1.DefaultVers
else if (this.minorPattern(commit)) {
type = VersionType_1.VersionType.Minor;
}
else {
if (this.patchPattern(commit) ||
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++;
}
}
if (this.enablePrereleaseMode && major === 0) {
switch (type) {
@ -743,7 +765,9 @@ class BumpAlwaysVersionClassifier extends DefaultVersionClassifier_1.DefaultVers
patch += 1;
increment = 0;
break;
default: break;
default:
increment++;
break;
}
}
else {
@ -762,7 +786,9 @@ class BumpAlwaysVersionClassifier extends DefaultVersionClassifier_1.DefaultVers
patch += 1;
increment = 0;
break;
default: break;
default:
increment++;
break;
}
}
}
@ -959,7 +985,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();
});
@ -1179,8 +1205,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);
});
@ -1342,7 +1368,7 @@ 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 = {}));
/***/ }),
@ -1904,7 +1930,7 @@ class OidcClient {
.catch(error => {
throw new Error(`Failed to get ID Token. \n
Error Code : ${error.statusCode}\n
Error Message: ${error.result.message}`);
Error Message: ${error.message}`);
});
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
if (!id_token) {
@ -3292,6 +3318,19 @@ class HttpClientResponse {
}));
});
}
readBodyBuffer() {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
const chunks = [];
this.message.on('data', (chunk) => {
chunks.push(chunk);
});
this.message.on('end', () => {
resolve(Buffer.concat(chunks));
});
}));
});
}
}
exports.HttpClientResponse = HttpClientResponse;
function isHttps(requestUrl) {
@ -3796,8 +3835,14 @@ function getProxyUrl(reqUrl) {
}
})();
if (proxyVar) {
try {
return new URL(proxyVar);
}
catch (_a) {
if (!proxyVar.startsWith('http://') && !proxyVar.startsWith('https://'))
return new URL(`http://${proxyVar}`);
}
}
else {
return undefined;
}
@ -3807,6 +3852,10 @@ function checkBypass(reqUrl) {
if (!reqUrl.hostname) {
return false;
}
const reqHost = reqUrl.hostname;
if (isLoopbackAddress(reqHost)) {
return true;
}
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
if (!noProxy) {
return false;
@ -3832,13 +3881,24 @@ function checkBypass(reqUrl) {
.split(',')
.map(x => x.trim().toUpperCase())
.filter(x => x)) {
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
if (upperNoProxyItem === '*' ||
upperReqHosts.some(x => x === upperNoProxyItem ||
x.endsWith(`.${upperNoProxyItem}`) ||
(upperNoProxyItem.startsWith('.') &&
x.endsWith(`${upperNoProxyItem}`)))) {
return true;
}
}
return false;
}
exports.checkBypass = checkBypass;
function isLoopbackAddress(host) {
const hostLower = host.toLowerCase();
return (hostLower === 'localhost' ||
hostLower.startsWith('127.') ||
hostLower.startsWith('[::1]') ||
hostLower.startsWith('[0:0:0:0:0:0:0:1]'));
}
//# sourceMappingURL=proxy.js.map
/***/ }),
@ -3878,11 +3938,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rename = exports.readlink = exports.readdir = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.READONLY = exports.UV_FS_O_EXLOCK = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports.rename = exports.readlink = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
const fs = __importStar(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017));
_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
_a = fs.promises
// export const {open} = 'fs'
, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
// export const {open} = 'fs'
exports.IS_WINDOWS = process.platform === 'win32';
// See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691
exports.UV_FS_O_EXLOCK = 0x10000000;
exports.READONLY = fs.constants.O_RDONLY;
function exists(fsPath) {
return __awaiter(this, void 0, void 0, function* () {
try {
@ -4063,12 +4129,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0;
const assert_1 = __nccwpck_require__(9491);
const childProcess = __importStar(__nccwpck_require__(2081));
const path = __importStar(__nccwpck_require__(1017));
const util_1 = __nccwpck_require__(3837);
const ioUtil = __importStar(__nccwpck_require__(1962));
const exec = util_1.promisify(childProcess.exec);
const execFile = util_1.promisify(childProcess.execFile);
/**
* Copies a file or folder.
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
@ -4149,61 +4211,23 @@ exports.mv = mv;
function rmRF(inputPath) {
return __awaiter(this, void 0, void 0, function* () {
if (ioUtil.IS_WINDOWS) {
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
// Check for invalid characters
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
if (/[*"<>|]/.test(inputPath)) {
throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
}
}
try {
const cmdPath = ioUtil.getCmdPath();
if (yield ioUtil.isDirectory(inputPath, true)) {
yield exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
env: { inputPath }
// note if path does not exist, error is silent
yield ioUtil.rm(inputPath, {
force: true,
maxRetries: 3,
recursive: true,
retryDelay: 300
});
}
else {
yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
env: { inputPath }
});
}
}
catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT')
throw err;
}
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that
try {
yield ioUtil.unlink(inputPath);
}
catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT')
throw err;
}
}
else {
let isDir = false;
try {
isDir = yield ioUtil.isDirectory(inputPath);
}
catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT')
throw err;
return;
}
if (isDir) {
yield execFile(`rm`, [`-rf`, `${inputPath}`]);
}
else {
yield ioUtil.unlink(inputPath);
}
throw new Error(`File was unable to be removed ${err}`);
}
});
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -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);
}

View file

@ -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;

View file

@ -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]];
}

View file

@ -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) ||
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++;
}
}
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;
}
}
}

View file

@ -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();
});

View file

@ -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);
});

View file

@ -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 = {}));

3312
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -28,20 +28,20 @@
},
"homepage": "https://github.com/paulhatch/semantic-version#readme",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1"
},
"devDependencies": {
"@types/node": "^18.11.9",
"@typescript-eslint/parser": "^5.17.0",
"@vercel/ncc": "^0.34.0",
"eslint": "^8.12.0",
"eslint-plugin-github": "^4.3.6",
"eslint-plugin-jest": "^27.1.3",
"jest": "^29.2.2",
"@types/node": "^20.7.1",
"@typescript-eslint/parser": "^6.7.3",
"@vercel/ncc": "^0.38.0",
"eslint": "^8.50.0",
"eslint-plugin-github": "^4.10.1",
"eslint-plugin-jest": "^27.4.0",
"jest": "^29.7.0",
"js-yaml": "^4.1.0",
"prettier": "^2.6.1",
"ts-jest": "^29.0.3",
"typescript": "^4.6.3"
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
}
}

View file

@ -2,10 +2,10 @@
import * as exec from '@actions/exec';
import { DebugManager } from './DebugManager';
const debugManager = DebugManager.getInstance();
export const cmd = async (command: string, ...args: any): Promise<string> => {
const debugManager = DebugManager.getInstance();
if (debugManager.isReplayMode()) {
return debugManager.replayCommand(command, args);
}

View file

@ -1,10 +1,8 @@
import exp from "constants";
import { ActionConfig } from "./ActionConfig";
/** Utility class for managing debug mode and diagnostic information */
export class DebugManager {
private constructor() { }
private static instance: DebugManager;
@ -16,6 +14,12 @@ export class DebugManager {
return DebugManager.instance;
}
/** Clears the singleton instance of the DebugManager (used for testing) */
public static clearState() {
DebugManager.instance = new DebugManager();
}
private debugEnabled: boolean = false;
private replayMode: boolean = false;
private diagnosticInfo: DiagnosticInfo | null = null;

View file

@ -5,6 +5,7 @@ import { DefaultTagFormatter } from './DefaultTagFormatter';
/** Default tag formatter which allows a prefix to be specified */
export class BranchVersioningTagFormatter extends DefaultTagFormatter {
private onVersionBranch: boolean;
private major: number;
private minor?: number;
@ -17,13 +18,19 @@ export class BranchVersioningTagFormatter extends DefaultTagFormatter {
return new RegExp(pattern);
}
constructor(config: ActionConfig, private branchName: string) {
constructor(config: ActionConfig, branchName: string) {
super(config);
const pattern = config.versionFromBranch === true ?
new RegExp("[0-9]+.[0-9]+$|[0-9]+$") :
this.getRegex(config.versionFromBranch as string);
const result = pattern.exec(branchName);
if (result === null) {
this.major = NaN;
this.onVersionBranch = false;
return;
}
let branchVersion: string;
switch (result?.length) {
case 1:
@ -36,6 +43,8 @@ export class BranchVersioningTagFormatter extends DefaultTagFormatter {
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'`);
@ -52,7 +61,24 @@ export class BranchVersioningTagFormatter extends DefaultTagFormatter {
}
}
public override GetPattern(): string {
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]`);
}
override IsValid(tag: string): boolean {
if (!this.onVersionBranch) {
return super.IsValid(tag);
}
if (!super.IsValid(tag)) {
return false;
}
@ -68,6 +94,10 @@ export class BranchVersioningTagFormatter extends DefaultTagFormatter {
}
override Parse(tag: string): [major: number, minor: number, patch: number] {
if (!this.onVersionBranch) {
return super.Parse(tag);
}
const parsed = super.Parse(tag);
return [this.major, this.minor || parsed[1], parsed[2]];
}

View file

@ -6,7 +6,7 @@ import { expect, test } from '@jest/globals'
import { runAction } from '../src/action';
import { ConfigurationProvider } from './ConfigurationProvider';
import { ActionConfig } from './ActionConfig';
import exp from 'constants';
import { DebugManager } from './DebugManager';
const windows = process.platform === "win32";
const timeout = 30000;
@ -42,6 +42,7 @@ const createTestRepo = (repoDefaultConfig?: Partial<ActionConfig>) => {
run(`git merge ${branch}`);
},
runAction: async (inputs?: Partial<ActionConfig>) => {
DebugManager.clearState();
let config = new ActionConfig();
config = { ...config, ...{ versionFormat: "${major}.${minor}.${patch}+${increment}" }, ...repoDefaultConfig, ...inputs };
process.chdir(repoDirectory);
@ -187,32 +188,6 @@ test('Version pulled from last release branch', async () => {
expect(result.formattedVersion).toBe('5.6.8+0');
}, timeout);
/* Removed for now
test('Tags on branches are used', async () => {
// This test checks that tags are counted correctly even if they are not on
// the main branch:
// master o--o--o--o <- expecting v0.0.2
// \
// release o--o <- taged v0.0.1
const repo = createTestRepo(); // 0.0.0+0
repo.makeCommit('Initial Commit'); // 0.0.1+0
repo.makeCommit('Second Commit'); // 0.0.1+1
repo.makeCommit('Third Commit'); // 0.1.1+2
repo.exec('git checkout -b release/0.0.1')
repo.makeCommit('Fourth Commit'); // 0.1.1+3
repo.exec('git tag v0.0.1');
repo.exec('git checkout master');
repo.makeCommit('Fifth Commit'); // 0.0.2.0
const result = await repo.runAction();
expect(result.formattedVersion).toBe('0.0.2+0');
});
*/
test('Merged tags do not affect version', async () => {
// This test checks that merges don't override tags

View file

@ -40,16 +40,14 @@ export class BumpAlwaysVersionClassifier extends DefaultVersionClassifier {
type = VersionType.Major;
} else if (this.minorPattern(commit)) {
type = VersionType.Minor;
} else {
if (this.patchPattern(commit) ||
} else if (this.patchPattern(commit) ||
(major === 0 && minor === 0 && patch === 0 && commitSet.commits.length > 0)) {
type = VersionType.Patch;
} else {
type = VersionType.None;
increment++;
}
}
if (this.enablePrereleaseMode && major === 0) {
switch (type) {
case VersionType.Major:
@ -62,7 +60,9 @@ export class BumpAlwaysVersionClassifier extends DefaultVersionClassifier {
patch += 1;
increment = 0;
break;
default: break;
default:
increment++;
break;
}
} else {
switch (type) {
@ -80,7 +80,9 @@ export class BumpAlwaysVersionClassifier extends DefaultVersionClassifier {
patch += 1;
increment = 0;
break;
default: break;
default:
increment++;
break;
}
}

View file

@ -107,8 +107,8 @@ export class DefaultVersionClassifier implements VersionClassifier {
// - 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(VersionType.None, currentIncremement, false, <number>lastRelease.currentMajor, <number>lastRelease.currentMinor, <number>lastRelease.currentPatch);
const currentIncrement = versionsMatch ? increment : 0;
return new VersionClassification(VersionType.None, currentIncrement, false, <number>lastRelease.currentMajor, <number>lastRelease.currentMinor, <number>lastRelease.currentPatch);
}