clarify debug messages

This commit is contained in:
David Hiendl 2023-12-02 18:44:21 +01:00
parent 664643a9d3
commit 26ec9eb688
3 changed files with 67 additions and 46 deletions

67
dist/index.js vendored
View File

@ -30780,6 +30780,7 @@ module.exports = parseParams
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/make namespace object */
@ -30805,14 +30806,15 @@ var __webpack_exports__ = {};
// ESM COMPAT FLAG
__nccwpck_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js
var core = __nccwpck_require__(2186);
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
var github = __nccwpck_require__(5438);
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js
var core = __nccwpck_require__(2186);
;// CONCATENATED MODULE: external "process"
const external_process_namespaceObject = require("process");
;// CONCATENATED MODULE: ./src/lib.js
function result_to_output(results) {
for (const key in results) {
if (!results.hasOwnProperty(key)) {
@ -30841,7 +30843,7 @@ const external_process_namespaceObject = require("process");
r.ci_hostname = url.hostname;
if (debug) {
console.log('results for output:', JSON.stringify(r, null, 2));
console.log('results for collect_ci:', JSON.stringify(r, null, 2));
}
if (output) {
result_to_output(r);
@ -30850,7 +30852,7 @@ const external_process_namespaceObject = require("process");
return r;
}
catch (error) {
console.log('partial results before error: ', JSON.stringify(r, null, 2));
console.log('partial results for collect_ci before error: ', JSON.stringify(r, null, 2));
core.setFailed(error.message);
external_process_namespaceObject.exit(1);
}
@ -31144,15 +31146,14 @@ const promises = {
semver_minor : false,
semver_patch : false,
semver_build : false,
semver_pre: false,
semver_pre : false
};
try {
const stripTagPrefix = core.getInput("strip_tag_prefix");
// TODO actually strip tag prefix
const stripTagPrefix = core.getInput('strip_tag_prefix');
if (debug) console.log(JSON.stringify(github.context, null, 2));
r.git_is_tag = github.context.ref.startsWith("refs/tags/");
r.git_is_tag = github.context.ref.startsWith('refs/tags/');
r.git_default_branch = github.context.payload?.repository?.defaultBranch;
r.git_is_pull_request = github.context.payload.pull_request != null;
@ -31160,32 +31161,39 @@ const promises = {
const baseRef = github.context.baseRef || external_process_namespaceObject.env.BODY_REF;
const headRef =
github.context.payload?.pull_request?.head?.ref || external_process_namespaceObject.env.HEAD_REF;
if (debug) console.log("baseRef=" + baseRef);
if (debug) console.log("headRef=" + headRef);
if (debug) {
console.log('baseRef=' + baseRef);
}
if (debug) {
console.log('headRef=' + headRef);
}
// TODO support PR data
} else if (!r.git_is_tag) {
}
else if (!r.git_is_tag) {
// regular branches
r.git_is_branch = true;
}
// gather regular branch info
if (r.git_is_branch) {
if (!github.context.ref.startsWith("refs/heads/")) {
if (!github.context.ref.startsWith('refs/heads/')) {
throw new Error(
"Failed to determine branch for non-PR and non-Tag action",
'Failed to determine branch for non-PR and non-Tag action'
);
}
r.git_current_branch = github.context.ref.slice("refs/heads/".length);
r.git_current_branch = github.context.ref.slice('refs/heads/'.length);
r.git_ref_branch = r.git_current_branch; // same as current branch for non-PR, non-Tag
r.git_is_default_branch = r.git_current_branch == r.git_default_branch;
}
// parse semver for tags
if (r.git_is_tag) {
r.git_tag = github.context.ref.slice("refs/tags/".length);
r.git_tag = github.context.ref.slice('refs/tags/'.length);
const parsed = parseSemVer(r.git_tag);
if (debug) console.log("semver=" + JSON.stringify(parsed));
if (debug) {
console.log('semver=' + JSON.stringify(parsed));
}
if (parsed.matches) {
r.semver_valid = parsed.matches;
@ -31195,9 +31203,12 @@ const promises = {
r.semver_build = parsed.build;
r.semver_pre = parsed.pre;
}
} else if (r.git_is_branch) {
}
else if (r.git_is_branch) {
const parsed = parseSemVer(r.git_current_branch);
if (debug) console.log("semver=" + JSON.stringify(parsed));
if (debug) {
console.log('semver=' + JSON.stringify(parsed));
}
if (parsed.matches) {
r.semver_valid = parsed.matches;
@ -31209,12 +31220,17 @@ const promises = {
}
}
if (debug) console.log("results for output:", JSON.stringify(r, null, 2));
if (output) result_to_output(r);
if (debug) {
console.log('results for collect_git:', JSON.stringify(r, null, 2));
}
if (output) {
result_to_output(r);
}
return r;
} catch (error) {
console.log("partial results before error: ", JSON.stringify(r, null, 2));
}
catch (error) {
console.log('partial results for collect_git before error: ', JSON.stringify(r, null, 2));
core.setFailed(error.message);
external_process_namespaceObject.exit(1);
}
@ -31224,6 +31240,11 @@ const promises = {
function collect_all(debug = false, output = false) {
if (debug) {
console.log(JSON.stringify(github.context, null, 2));
}
collect_ci(debug, output);
collect_git(debug, output);
}

View File

@ -13,7 +13,7 @@ export function collect_ci(debug = false, output = false) {
r.ci_hostname = url.hostname;
if (debug) {
console.log('results for output:', JSON.stringify(r, null, 2));
console.log('results for collect_ci:', JSON.stringify(r, null, 2));
}
if (output) {
result_to_output(r);
@ -22,7 +22,7 @@ export function collect_ci(debug = false, output = false) {
return r;
}
catch (error) {
console.log('partial results before error: ', JSON.stringify(r, null, 2));
console.log('partial results for collect_ci before error: ', JSON.stringify(r, null, 2));
core.setFailed(error.message);
process.exit(1);
}

View File

@ -93,7 +93,7 @@ export function collect_git(debug = false, output = false) {
}
if (debug) {
console.log('results for output:', JSON.stringify(r, null, 2));
console.log('results for collect_git:', JSON.stringify(r, null, 2));
}
if (output) {
result_to_output(r);
@ -102,7 +102,7 @@ export function collect_git(debug = false, output = false) {
return r;
}
catch (error) {
console.log("partial results before error: ", JSON.stringify(r, null, 2));
console.log('partial results for collect_git before error: ', JSON.stringify(r, null, 2));
core.setFailed(error.message);
process.exit(1);
}