Skip to content

Commit

Permalink
fix(set-shas): Fixed incorrect base sha if no tags exist (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs authored Dec 9, 2023
2 parents ea131a8 + 9086868 commit 8f6b0c2
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 103 deletions.
161 changes: 62 additions & 99 deletions actions/set-shas/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 <https://github.com/jonschlinkert/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:
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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 <https://github.com/jonschlinkert/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:
Expand Down Expand Up @@ -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 <https://github.com/jonschlinkert/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:
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions actions/set-shas/dist/src/utils/exec.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference types="node" />
import { ShellString, ExecOptions } from 'shelljs';
import { ChildProcess } from 'child_process';
export interface Options extends ExecOptions {
Expand Down
19 changes: 15 additions & 4 deletions actions/set-shas/src/set-shas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`)
}
Expand Down

0 comments on commit 8f6b0c2

Please sign in to comment.