From 80985c8d4b29884e086b1608be5205781e81432d Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Mon, 22 May 2023 15:58:06 -0500 Subject: [PATCH] chore: update changlelog script to handle revert pr ref (#26801) --- .../semantic-commits/get-binary-release-data.js | 16 ++++++++++++---- .../validate-binary-changelog.js | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/semantic-commits/get-binary-release-data.js b/scripts/semantic-commits/get-binary-release-data.js index 71787718baa5..f3febdffa570 100644 --- a/scripts/semantic-commits/get-binary-release-data.js +++ b/scripts/semantic-commits/get-binary-release-data.js @@ -66,7 +66,15 @@ const getReleaseData = async (latestReleaseInfo) => { const { type: semanticType, references } = semanticResult - if (!references.length || !references[0].issue) { + if (!references.length) { + console.log('Commit does not have an associated pull request number...') + + return + } + + const ref = references.find((r) => !r.raw.includes('revert #')) + + if (!ref) { console.log('Commit does not have an associated pull request number...') return @@ -75,7 +83,7 @@ const getReleaseData = async (latestReleaseInfo) => { const { data: pullRequest } = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', { owner: 'cypress-io', repo: 'cypress', - pull_number: references[0].issue, + pull_number: ref.issue, }) const associatedIssues = getLinkedIssues(pullRequest.body) @@ -83,11 +91,11 @@ const getReleaseData = async (latestReleaseInfo) => { commits.push({ commitMessage: semanticResult.header, semanticType, - prNumber: references[0].issue, + prNumber: ref.issue, associatedIssues, }) - prsInRelease.push(`https://github.com/cypress-io/cypress/pull/${references[0].issue}`) + prsInRelease.push(`https://github.com/cypress-io/cypress/pull/${ref.issue}`) associatedIssues.forEach((issueNumber) => { issuesInRelease.push(`https://github.com/cypress-io/cypress/issues/${issueNumber}`) diff --git a/scripts/semantic-commits/validate-binary-changelog.js b/scripts/semantic-commits/validate-binary-changelog.js index 094d8df20a50..9d0ac025377b 100644 --- a/scripts/semantic-commits/validate-binary-changelog.js +++ b/scripts/semantic-commits/validate-binary-changelog.js @@ -12,7 +12,7 @@ const changelog = async () => { if (process.env.CIRCLECI) { console.log({ checkedInBinaryVersion }) - if (process.env.CIRCLE_BRANCH !== 'develop' && process.env.CIRCLE_BRANCH !== 'release-12.5.0' && !/^release\/\d+\.\d+\.\d+$/.test(process.env.CIRCLE_BRANCH) && !hasVersionBump) { + if (process.env.CIRCLE_BRANCH !== 'develop' && process.env.CIRCLE_BRANCH !== 'fix-changelog-script' && !/^release\/\d+\.\d+\.\d+$/.test(process.env.CIRCLE_BRANCH) && !hasVersionBump) { console.log('Only verify the entire changelog for develop, a release branch or any branch that bumped to the Cypress version in the package.json.') return