From d4ff9c201201496d5bc84c7b507594e1829c1286 Mon Sep 17 00:00:00 2001 From: robgutsopedra <101654801+robgutsopedra@users.noreply.github.com> Date: Mon, 1 Aug 2022 10:02:09 +0200 Subject: [PATCH] feat: PLT-239 git diff of tags in changelog (#4) --- action.yml | 3 --- dist/index.js | 14 +------------- src/index.ts | 15 ++------------- 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/action.yml b/action.yml index 8fe8baa..44d5814 100644 --- a/action.yml +++ b/action.yml @@ -21,9 +21,6 @@ inputs: description: 'Update changelog' required: false default: true - merged_branch: - description: 'Merged branch - only necessary for adding some info to changelog' - required: false initial_release: description: 'In case no release is present in the repo, which one should be the base release from which to bump - defaults to 0.0.0' required: false diff --git a/dist/index.js b/dist/index.js index e206405..14e50e9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9190,19 +9190,7 @@ const start = async () => { const fileSha = fileToUpdate.data.sha; const fileContent = gBase64.decode(fileToUpdate.data.content); const changelogDate = new Date(); - let updatedFileContent = gBase64.encode(changelogDate.toISOString().split('T')[0] + ", " + nextReleaseTag + "\n\n" + `\t${String.fromCodePoint(0x2022)} ${commitMessage.repository.pullRequest.mergeCommit.messageHeadline} (${commitMessage.repository.pullRequest.mergeCommit.author.name})\n` + fileContent); - let diffMergedBranch; - console.log("What is merged_branch?" + core.getInput('merged_branch')); - if (core.getInput('merged_branch')) { - diffMergedBranch = await octokit.request(`GET /repos/{owner}/{repo}/compare/{base}...{head}`, { - repo: repoDetails.repoName, - owner: repoDetails.repoOwner, - base: "main", - head: core.getInput('merged_branch') - }); - console.log("tagDiffs is " + diffMergedBranch.data.html_url); - updatedFileContent = gBase64.encode(changelogDate.toISOString().split('T')[0] + ", " + nextReleaseTag + "\n\n" + `\t${String.fromCodePoint(0x2022)} Commit --> ${commitMessage.repository.pullRequest.mergeCommit.messageHeadline} (${commitMessage.repository.pullRequest.mergeCommit.author.name})\n` + `\t${String.fromCodePoint(0x2022)} Diff --> ${diffMergedBranch.data.html_url}\n` + fileContent); - } + updatedFileContent = gBase64.encode(changelogDate.toISOString().split('T')[0] + ", " + nextReleaseTag + "\n\n" + `\t${String.fromCodePoint(0x2022)} Commit --> ${commitMessage.repository.pullRequest.mergeCommit.messageHeadline} (${commitMessage.repository.pullRequest.mergeCommit.author.name})\n` + `\t${String.fromCodePoint(0x2022)} Diff --> https://github.com/${repoDetails.repoOwner}/${repoDetails.repoName}/compare/${latestVersion}...${nextReleaseTag}\n` + fileContent); const changelogResult = await octokit.request(`PUT /repos/{owner}/{repo}/contents/${repoDetails.changelogFile}`, { repo: repoDetails.repoName, owner: repoDetails.repoOwner, diff --git a/src/index.ts b/src/index.ts index cba64f8..2fefebe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -106,19 +106,8 @@ const start = async () => { const fileSha = fileToUpdate.data.sha const fileContent = Base64.decode(fileToUpdate.data.content) const changelogDate = new Date() - let updatedFileContent = Base64.encode(changelogDate.toISOString().split('T')[0] + ", " + nextReleaseTag + "\n\n" + `\t${String.fromCodePoint(0x2022)} ${commitMessage.repository.pullRequest.mergeCommit.messageHeadline} (${commitMessage.repository.pullRequest.mergeCommit.author.name})\n` + fileContent) - let diffMergedBranch - console.log("What is merged_branch?" + core.getInput('merged_branch')) - if(core.getInput('merged_branch')){ - diffMergedBranch = await octokit.request(`GET /repos/{owner}/{repo}/compare/{base}...{head}`, { - repo: repoDetails.repoName, - owner: repoDetails.repoOwner, - base: "main", - head: core.getInput('merged_branch') - }) - console.log("tagDiffs is " + diffMergedBranch.data.html_url) - updatedFileContent = Base64.encode(changelogDate.toISOString().split('T')[0] + ", " + nextReleaseTag + "\n\n" + `\t${String.fromCodePoint(0x2022)} Commit --> ${commitMessage.repository.pullRequest.mergeCommit.messageHeadline} (${commitMessage.repository.pullRequest.mergeCommit.author.name})\n` + `\t${String.fromCodePoint(0x2022)} Diff --> ${diffMergedBranch.data.html_url}\n` + fileContent) - } + updatedFileContent = Base64.encode(changelogDate.toISOString().split('T')[0] + ", " + nextReleaseTag + "\n\n" + `\t${String.fromCodePoint(0x2022)} Commit --> ${commitMessage.repository.pullRequest.mergeCommit.messageHeadline} (${commitMessage.repository.pullRequest.mergeCommit.author.name})\n` + `\t${String.fromCodePoint(0x2022)} Diff --> https://github.com/${repoDetails.repoOwner}/${repoDetails.repoName}/compare/${latestVersion}...${nextReleaseTag}\n` + fileContent) + const changelogResult = await octokit.request(`PUT /repos/{owner}/{repo}/contents/${repoDetails.changelogFile}`, { repo: repoDetails.repoName, owner: repoDetails.repoOwner,