From 9086868cfa99070a9c02f4d8c2c879be30ed9e6e Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Sat, 9 Dec 2023 17:25:48 +0100 Subject: [PATCH] fix(set-shas): Fixed incorrect base sha if no tags exist --- actions/set-shas/dist/index.js | 161 +++++++++------------- actions/set-shas/dist/src/utils/exec.d.ts | 1 + actions/set-shas/src/set-shas.ts | 19 ++- 3 files changed, 78 insertions(+), 103 deletions(-) diff --git a/actions/set-shas/dist/index.js b/actions/set-shas/dist/index.js index f5e502c1..0c910eca 100644 --- a/actions/set-shas/dist/index.js +++ b/actions/set-shas/dist/index.js @@ -558,7 +558,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) { @@ -2248,7 +2248,7 @@ exports.Octokit = Octokit; Object.defineProperty(exports, "__esModule", ({ value: true })); -var isPlainObject = __nccwpck_require__(8358); +var isPlainObject = __nccwpck_require__(1716); var universalUserAgent = __nccwpck_require__(4021); function lowercaseKeys(object) { @@ -2636,52 +2636,6 @@ exports.endpoint = endpoint; //# sourceMappingURL=index.js.map -/***/ }), - -/***/ 8358: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ value: true })); - -/*! - * is-plain-object - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ - -function isObject(o) { - return Object.prototype.toString.call(o) === '[object Object]'; -} - -function isPlainObject(o) { - var ctor,prot; - - if (isObject(o) === false) return false; - - // If has modified constructor - ctor = o.constructor; - if (ctor === undefined) return true; - - // If has modified prototype - prot = ctor.prototype; - if (isObject(prot) === false) return false; - - // If constructor does not have an Object-specific method - if (prot.hasOwnProperty('isPrototypeOf') === false) { - return false; - } - - // Most likely a plain Object - return true; -} - -exports.isPlainObject = isPlainObject; - - /***/ }), /***/ 4703: @@ -4232,7 +4186,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau var endpoint = __nccwpck_require__(9779); var universalUserAgent = __nccwpck_require__(4021); -var isPlainObject = __nccwpck_require__(9593); +var isPlainObject = __nccwpck_require__(1716); var nodeFetch = _interopDefault(__nccwpck_require__(7002)); var requestError = __nccwpck_require__(9167); @@ -4403,52 +4357,6 @@ exports.request = request; //# sourceMappingURL=index.js.map -/***/ }), - -/***/ 9593: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ value: true })); - -/*! - * is-plain-object - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ - -function isObject(o) { - return Object.prototype.toString.call(o) === '[object Object]'; -} - -function isPlainObject(o) { - var ctor,prot; - - if (isObject(o) === false) return false; - - // If has modified constructor - ctor = o.constructor; - if (ctor === undefined) return true; - - // If has modified prototype - prot = ctor.prototype; - if (isObject(prot) === false) return false; - - // If constructor does not have an Object-specific method - if (prot.hasOwnProperty('isPrototypeOf') === false) { - return false; - } - - // Most likely a plain Object - return true; -} - -exports.isPlainObject = isPlainObject; - - /***/ }), /***/ 4015: @@ -9824,6 +9732,52 @@ if (typeof Object.create === 'function') { } +/***/ }), + +/***/ 1716: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +/*! + * is-plain-object + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ + +function isObject(o) { + return Object.prototype.toString.call(o) === '[object Object]'; +} + +function isPlainObject(o) { + var ctor,prot; + + if (isObject(o) === false) return false; + + // If has modified constructor + ctor = o.constructor; + if (ctor === undefined) return true; + + // If has modified prototype + prot = ctor.prototype; + if (isObject(prot) === false) return false; + + // If constructor does not have an Object-specific method + if (prot.hasOwnProperty('isPrototypeOf') === false) { + return false; + } + + // Most likely a plain Object + return true; +} + +exports.isPlainObject = isPlainObject; + + /***/ }), /***/ 4546: @@ -20747,10 +20701,19 @@ function run() { asString: true, silent: !core.isDebug() }); - baseSha = (0, exec_1.execCommand)(`git rev-parse ${tag}^{commit}`, { - asString: true, - silent: !core.isDebug() - }); + if (!tag) { + core.warning(`No tags found, get base sha from origin!`); + baseSha = (0, exec_1.execCommand)(`git rev-parse origin/${mainBranchName}~1`, { + asString: true, + silent: !core.isDebug() + }); + } + else { + baseSha = (0, exec_1.execCommand)(`git rev-parse ${tag}^{commit}`, { + asString: true, + silent: !core.isDebug() + }); + } core.info(`Got base sha "${baseSha}" from "${tag}"`); } core.setOutput('base', baseSha); diff --git a/actions/set-shas/dist/src/utils/exec.d.ts b/actions/set-shas/dist/src/utils/exec.d.ts index 90bb00be..152e98c5 100644 --- a/actions/set-shas/dist/src/utils/exec.d.ts +++ b/actions/set-shas/dist/src/utils/exec.d.ts @@ -1,3 +1,4 @@ +/// import { ShellString, ExecOptions } from 'shelljs'; import { ChildProcess } from 'child_process'; export interface Options extends ExecOptions { diff --git a/actions/set-shas/src/set-shas.ts b/actions/set-shas/src/set-shas.ts index fbec0576..9ec992cf 100644 --- a/actions/set-shas/src/set-shas.ts +++ b/actions/set-shas/src/set-shas.ts @@ -25,10 +25,21 @@ async function run() { asString: true, silent: !core.isDebug() }) - baseSha = execCommand(`git rev-parse ${tag}^{commit}`, { - asString: true, - silent: !core.isDebug() - }) + + if (!tag) { + core.warning(`No tags found, get base sha from origin!`) + + baseSha = execCommand(`git rev-parse origin/${mainBranchName}~1`, { + asString: true, + silent: !core.isDebug() + }) + + } else { + baseSha = execCommand(`git rev-parse ${tag}^{commit}`, { + asString: true, + silent: !core.isDebug() + }) + } core.info(`Got base sha "${baseSha}" from "${tag}"`) }