From 3edcef61873c683f3a80000a0ce2a540724339fa Mon Sep 17 00:00:00 2001 From: Donald Wasserman Date: Mon, 18 May 2020 15:30:39 -0400 Subject: [PATCH] add default branch checking for cases when use_pullrequest is true, but no branch is provided --- dist/index.js | 11 +++++++++-- index.js | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 8db8f4e..9c25358 100644 --- a/dist/index.js +++ b/dist/index.js @@ -536,7 +536,9 @@ async function run() { changelogExists = false; } - let { url, tag, name, body, releaseBranch } = getReleaseData(eventPath); + let { url, tag, name, body, releaseBranch, repoDefaultBranch } = getReleaseData( + eventPath + ); let branch = defaultBranch || releaseBranch; @@ -559,6 +561,10 @@ async function run() { let prBranch = core.getInput('branch_name') || `changelog-${tag}`; + if (!prBranch) { + prBranch = repoDefaultBranch; + } + if (usePr) { let refSha; try { @@ -618,7 +624,8 @@ function getReleaseData(eventPath) { target_commitish: releaseBranch } = event.release; - return { url, tag, name, body, releaseBranch }; + let { default_branch: repoDefaultBranch } = event.repository; + return { url, tag, name, body, releaseBranch, repoDefaultBranch }; } run(); diff --git a/index.js b/index.js index 18437b2..9ce3c06 100644 --- a/index.js +++ b/index.js @@ -42,7 +42,9 @@ async function run() { changelogExists = false; } - let { url, tag, name, body, releaseBranch } = getReleaseData(eventPath); + let { url, tag, name, body, releaseBranch, repoDefaultBranch } = getReleaseData( + eventPath + ); let branch = defaultBranch || releaseBranch; @@ -65,6 +67,10 @@ async function run() { let prBranch = core.getInput('branch_name') || `changelog-${tag}`; + if (!prBranch) { + prBranch = repoDefaultBranch; + } + if (usePr) { let refSha; try { @@ -124,7 +130,8 @@ function getReleaseData(eventPath) { target_commitish: releaseBranch } = event.release; - return { url, tag, name, body, releaseBranch }; + let { default_branch: repoDefaultBranch } = event.repository; + return { url, tag, name, body, releaseBranch, repoDefaultBranch }; } run();