From 66b83c9642ed75108124b9c915215230cdf9b60c Mon Sep 17 00:00:00 2001 From: garronej Date: Wed, 19 Jan 2022 01:26:19 +0100 Subject: [PATCH] Fix previous commit --- dist/index.js | 10 ++++++++-- src/tell_if_project_uses_npm_or_yarn.ts | 5 ++++- src/update_changelog.ts | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9efb914..d19b691 100644 --- a/dist/index.js +++ b/dist/index.js @@ -921,7 +921,10 @@ function action(_actionName, params, core) { return __awaiter(this, void 0, void 0, function* () { core.debug(JSON.stringify(params)); const { owner, repo } = params; - const branch = params.branch.split("/").reverse()[0]; + //params.branch <- github.head_ref || github.ref + //When it's a normal branch: github.head_ref==="" and github.ref==="refs/heads/main" + //When it's a pr from: github.head_ref==="" + const branch = params.branch.replace(/^refs\/heads\//, ""); const npm_or_yarn = yield node_fetch_1.default(urlJoin("https://raw.github.com", owner, repo, branch, "yarn.lock")).then(res => res.status === 404 ? "npm" : "yarn"); core.debug(`Version on ${owner}/${repo}#${branch} is using ${npm_or_yarn}`); return { npm_or_yarn }; @@ -9168,7 +9171,10 @@ function action(_actionName, params, core) { var _a; return __awaiter(this, void 0, void 0, function* () { const { owner, repo, github_token } = params; - const branch = params.branch.split("/").reverse()[0]; + //params.branch <- github.head_ref || github.ref + //When it's a normal branch: github.head_ref==="" and github.ref==="refs/heads/main" + //When it's a pr from: github.head_ref==="" + const branch = params.branch.replace(/^refs\/heads\//, ""); core.debug(`params: ${JSON.stringify(params)}`); const exclude_commit_from_author_names = JSON.parse(params.exclude_commit_from_author_names_json); const octokit = createOctokit_1.createOctokit({ github_token }); diff --git a/src/tell_if_project_uses_npm_or_yarn.ts b/src/tell_if_project_uses_npm_or_yarn.ts index 00b56d5..2fb229a 100644 --- a/src/tell_if_project_uses_npm_or_yarn.ts +++ b/src/tell_if_project_uses_npm_or_yarn.ts @@ -31,7 +31,10 @@ export async function action( const { owner, repo } = params; - const branch = params.branch.split("/").reverse()[0]; + //params.branch <- github.head_ref || github.ref + //When it's a normal branch: github.head_ref==="" and github.ref==="refs/heads/main" + //When it's a pr from: github.head_ref==="" + const branch = params.branch.replace(/^refs\/heads\//, ""); const npm_or_yarn = await fetch( urlJoin( diff --git a/src/update_changelog.ts b/src/update_changelog.ts index f23fdbd..cd60dd0 100644 --- a/src/update_changelog.ts +++ b/src/update_changelog.ts @@ -39,7 +39,10 @@ export async function action( github_token } = params; - const branch = params.branch.split("/").reverse()[0]; + //params.branch <- github.head_ref || github.ref + //When it's a normal branch: github.head_ref==="" and github.ref==="refs/heads/main" + //When it's a pr from: github.head_ref==="" + const branch = params.branch.replace(/^refs\/heads\//, ""); core.debug(`params: ${JSON.stringify(params)}`);