From 255068791d0172da68eb6de1ee734b896db9cbfd Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Mon, 1 Nov 2021 19:29:47 +0000 Subject: [PATCH 01/15] Filter out the commits introduced by cherry picking --- .github/libs/GitUtils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index 5f86983ac6c3..bdcdcf0e5635 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -14,7 +14,10 @@ function getPullRequestsMergedBetween(fromRef, toRef) { console.log('Running command: ', command); const localGitLogs = execSync(command).toString(); return _.map( - [...localGitLogs.matchAll(/Merge pull request #(\d{1,6}) from (?!Expensify\/(?:master|main|version-))/g)], + _.filter( + [...localGitLogs.matchAll(/Merge pull request #(\d{1,6}) from (?!Expensify\/(?:master|main|version-))/g)], + commitMessage => !commitMessage.match(/\(cherry picked from commit/g) + ), match => match[1], ); } From 4664a8a672d7633af4bfef12dbaa8ba47dbed3af Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Mon, 1 Nov 2021 19:32:27 +0000 Subject: [PATCH 02/15] Add comment --- .github/libs/GitUtils.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index bdcdcf0e5635..5bedbc6a01fb 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -13,6 +13,8 @@ function getPullRequestsMergedBetween(fromRef, toRef) { console.log('Getting pull requests merged between the following refs:', fromRef, toRef); console.log('Running command: ', command); const localGitLogs = execSync(command).toString(); + + // Filter out merge commits which are introduced by cherry-picking return _.map( _.filter( [...localGitLogs.matchAll(/Merge pull request #(\d{1,6}) from (?!Expensify\/(?:master|main|version-))/g)], From 62799cfad7c71597c671ab1491dc13a8434dfd9d Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Mon, 1 Nov 2021 21:53:42 +0000 Subject: [PATCH 03/15] Update the regex and format of log --- .github/libs/GitUtils.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index 5bedbc6a01fb..c9b8b8f89e76 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -9,17 +9,14 @@ const {execSync} = require('child_process'); * @returns {Array} */ function getPullRequestsMergedBetween(fromRef, toRef) { - const command = `git log --format="%s" ${fromRef}...${toRef}`; + const command = `git log --format="{[%B]}" ${fromRef}...${toRef}`; console.log('Getting pull requests merged between the following refs:', fromRef, toRef); console.log('Running command: ', command); const localGitLogs = execSync(command).toString(); - // Filter out merge commits which are introduced by cherry-picking + // Remove the PRs which are duplicated by cherry pick return _.map( - _.filter( - [...localGitLogs.matchAll(/Merge pull request #(\d{1,6}) from (?!Expensify\/(?:master|main|version-))/g)], - commitMessage => !commitMessage.match(/\(cherry picked from commit/g) - ), + [...localGitLogs.matchAll(/{\[Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:[\s\S]*\(cherry picked from commit .*\)\s\]}))/g)], match => match[1], ); } From 11e758036d84493d7957540275c8f22bb32de74f Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Mon, 1 Nov 2021 21:55:46 +0000 Subject: [PATCH 04/15] Update tests --- tests/unit/GitUtilsTest.js | 44 +++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/tests/unit/GitUtilsTest.js b/tests/unit/GitUtilsTest.js index 623c6c25e24d..d991ece8afbb 100644 --- a/tests/unit/GitUtilsTest.js +++ b/tests/unit/GitUtilsTest.js @@ -22,21 +22,45 @@ const data = [ result: ['337', '336', '331', '330', '333', '332'], }, { - gitLog: `Merge pull request #1521 from parasharrajat/parasharrajat/pdf-render - Merge pull request #1563 from Expensify/version-bump-e6498075e301df3e9c8d7866ea391a23c19ed9b0 + gitLog: `{[Merge pull request #1521 from parasharrajat/parasharrajat/pdf-render + ]} + {[Merge pull request #1563 from Expensify/version-bump-e6498075e301df3e9c8d7866ea391a23c19ed9b0 Update version to 1.0.1-470 - Merge pull request #1557 from aliabbasmalik8/IS-1500-compose-field-alignment-issue - Merge pull request #1562 from Expensify/version-bump-b9c85aa97dfb656b01a83871b4bbaed5e287c8b7 + ]} + {[Merge pull request #1557 from aliabbasmalik8/IS-1500-compose-field-alignment-issue + ]} + {[Merge pull request #1562 from Expensify/version-bump-b9c85aa97dfb656b01a83871b4bbaed5e287c8b7 Update version to 1.0.1-469 - Merge pull request #1515 from anthony-hull/typos + ]} + {[Merge pull request #1515 from anthony-hull/typos [IS-1500] Updated textalignInput utility - Merge pull request #1560 from Expensify/version-bump-b742a55d18e761cd7adb0849a29cfb48b3a04f99 + ]} + {[Merge pull request #1560 from Expensify/version-bump-b742a55d18e761cd7adb0849a29cfb48b3a04f99 Update version to 1.0.1-468 - Merge pull request #1555 from SameeraMadushan/sameera-IsAppInstalledLogic - Merge pull request #1 from Expensify/master - Merge pull request #2 from Expensify/main + ]} + {[Merge pull request #1555 from SameeraMadushan/sameera-IsAppInstalledLogic + ]} + {[Merge pull request #1 from Expensify/master + ]} + {[Merge pull request #2 from Expensify/main fix: set pdf width on large screens - [IS-1500] Fixed compose field alignment issue`, + [IS-1500] Fixed compose field alignment issue + ]} + {[Merge pull request #5812 from akshayasalvi/tooltip-workspace-name … + 42b5016 + Added tooltip for workspace name + + (cherry picked from commit a77d468) + ]} + {[Merge pull request #5813 from akshayasalvi/tooltip-workspace-name … + 42b5016 + Added tooltip for workspace name + + (cherry picked from commit a77d468) + ]} + {[Merge pull request #9 from Expensify/main + fix: set pdf width on large screens + ]}`, result: ['1521', '1557', '1515', '1555'], }, { From d283a8344185a6e8196337c3bd60345dc5d33829 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Mon, 1 Nov 2021 21:57:53 +0000 Subject: [PATCH 05/15] Update gitutils git log tests --- tests/unit/GitUtilsTest.js | 60 +++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/tests/unit/GitUtilsTest.js b/tests/unit/GitUtilsTest.js index d991ece8afbb..ca8d43b63ab7 100644 --- a/tests/unit/GitUtilsTest.js +++ b/tests/unit/GitUtilsTest.js @@ -6,45 +6,64 @@ const {execSync} = childProcess; const data = [ { - gitLog: `Start adding StagingDeployCash logic - Setting up bones - Merge pull request #337 from Expensify/francoisUpdateQbdSyncManager - Merge pull request #336 from Expensify/andrew-pr-cla - Update QBD Sync Manager version - Only run CLA on PR comments or events - Merge pull request #331 from Expensify/marcaaron-killMoment - Merge pull request #330 from Expensify/andrew-cla-update - Merge pull request #333 from Expensify/Rory-AddOnOffSwitchTooltip - Setup OnOffSwitch component with tooltips - Merge pull request #332 from Expensify/alex-mechler-patch-1 - Return to old hash-based deploy instrcutions - Remove DEFAULT_START_DATE & DEFAULT_END_DATE altogether`, + gitLog: `{[Start adding StagingDeployCash logic + ]} + {[Setting up bones + ]} + {[Merge pull request #337 from Expensify/francoisUpdateQbdSyncManager + ]} + {[Merge pull request #336 from Expensify/andrew-pr-cla + ]} + {[Update QBD Sync Manager version + ]} + {[Only run CLA on PR comments or events + ]} + {[Merge pull request #331 from Expensify/marcaaron-killMoment + ]} + {[Merge pull request #330 from Expensify/andrew-cla-update + ]} + {[Merge pull request #333 from Expensify/Rory-AddOnOffSwitchTooltip + ]} + {[Setup OnOffSwitch component with tooltips + ]} + {[Merge pull request #332 from Expensify/alex-mechler-patch-1 + ]} + {[Return to old hash-based deploy instrcutions + ]} + {[Remove DEFAULT_START_DATE & DEFAULT_END_DATE altogether + ]}`, result: ['337', '336', '331', '330', '333', '332'], }, { gitLog: `{[Merge pull request #1521 from parasharrajat/parasharrajat/pdf-render ]} {[Merge pull request #1563 from Expensify/version-bump-e6498075e301df3e9c8d7866ea391a23c19ed9b0 - Update version to 1.0.1-470 + ]} + {[Update version to 1.0.1-470 ]} {[Merge pull request #1557 from aliabbasmalik8/IS-1500-compose-field-alignment-issue ]} {[Merge pull request #1562 from Expensify/version-bump-b9c85aa97dfb656b01a83871b4bbaed5e287c8b7 - Update version to 1.0.1-469 + ]} + {[Update version to 1.0.1-469 ]} {[Merge pull request #1515 from anthony-hull/typos - [IS-1500] Updated textalignInput utility + ]} + {[[IS-1500] Updated textalignInput utility ]} {[Merge pull request #1560 from Expensify/version-bump-b742a55d18e761cd7adb0849a29cfb48b3a04f99 - Update version to 1.0.1-468 + ]} + {[Update version to 1.0.1-468 ]} {[Merge pull request #1555 from SameeraMadushan/sameera-IsAppInstalledLogic ]} {[Merge pull request #1 from Expensify/master ]} {[Merge pull request #2 from Expensify/main - fix: set pdf width on large screens - [IS-1500] Fixed compose field alignment issue + ]} + {[fix: set pdf width on large screens + ]} + {[[IS-1500] Fixed compose field alignment issue ]} {[Merge pull request #5812 from akshayasalvi/tooltip-workspace-name … 42b5016 @@ -59,7 +78,8 @@ const data = [ (cherry picked from commit a77d468) ]} {[Merge pull request #9 from Expensify/main - fix: set pdf width on large screens + ]} + {[fix: set pdf width on large screens ]}`, result: ['1521', '1557', '1515', '1555'], }, From b911b88e36ed6e72222455c71f44610a5d22c6ef Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Mon, 1 Nov 2021 22:54:24 +0000 Subject: [PATCH 06/15] Update unit test and regex for cherry pick commit message --- .github/libs/GitUtils.js | 2 +- tests/unit/GitUtilsTest.js | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index c9b8b8f89e76..04006a705467 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -16,7 +16,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { // Remove the PRs which are duplicated by cherry pick return _.map( - [...localGitLogs.matchAll(/{\[Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:[\s\S]*\(cherry picked from commit .*\)\s\]}))/g)], + [...localGitLogs.matchAll(/{\[Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:[^(\]})]*\(cherry picked from commit .*\)\s*\]}))/g)], match => match[1], ); } diff --git a/tests/unit/GitUtilsTest.js b/tests/unit/GitUtilsTest.js index ca8d43b63ab7..f10e02839cc0 100644 --- a/tests/unit/GitUtilsTest.js +++ b/tests/unit/GitUtilsTest.js @@ -71,22 +71,31 @@ const data = [ (cherry picked from commit a77d468) ]} - {[Merge pull request #5813 from akshayasalvi/tooltip-workspace-name … + {[Merge pull request #5813 from Expensify/master … 42b5016 Added tooltip for workspace name (cherry picked from commit a77d468) ]} + {[Merge pull request #1111 from akshayasalvi/tooltip-workspace-name … + 42b5016 + Added tooltip for workspace name + + (something else than cherry pick commit a77d468) + ]} {[Merge pull request #9 from Expensify/main ]} {[fix: set pdf width on large screens ]}`, - result: ['1521', '1557', '1515', '1555'], + result: ['1521', '1557', '1515', '1555', '1111'], }, { - gitLog: `Return to old hash-based deploy instrcutions - Remove DEFAULT_START_DATE & DEFAULT_END_DATE altogether - refactor`, + gitLog: `{[Return to old hash-based deploy instrcutions + ]} + {[Remove DEFAULT_START_DATE & DEFAULT_END_DATE altogether + ]} + {[refactor + ]}`, result: [], }, ]; From 4bda84c993a86c0d7554211f05bf0239c794af1b Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Mon, 1 Nov 2021 23:29:24 +0000 Subject: [PATCH 07/15] Build the Github Actions --- .github/actions/createOrUpdateStagingDeploy/index.js | 6 ++++-- .github/actions/getDeployPullRequestList/index.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index 13c93feb2d24..c2ed20d943ec 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -195,12 +195,14 @@ const {execSync} = __nccwpck_require__(3129); * @returns {Array} */ function getPullRequestsMergedBetween(fromRef, toRef) { - const command = `git log --format="%s" ${fromRef}...${toRef}`; + const command = `git log --format="{[%B]}" ${fromRef}...${toRef}`; console.log('Getting pull requests merged between the following refs:', fromRef, toRef); console.log('Running command: ', command); const localGitLogs = execSync(command).toString(); + + // Remove the PRs which are duplicated by cherry pick return _.map( - [...localGitLogs.matchAll(/Merge pull request #(\d{1,6}) from (?!Expensify\/(?:master|main|version-))/g)], + [...localGitLogs.matchAll(/{\[Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:[^(\]})]*\(cherry picked from commit .*\)\s*\]}))/g)], match => match[1], ); } diff --git a/.github/actions/getDeployPullRequestList/index.js b/.github/actions/getDeployPullRequestList/index.js index 6eca50094531..925db29f234b 100644 --- a/.github/actions/getDeployPullRequestList/index.js +++ b/.github/actions/getDeployPullRequestList/index.js @@ -117,12 +117,14 @@ const {execSync} = __nccwpck_require__(3129); * @returns {Array} */ function getPullRequestsMergedBetween(fromRef, toRef) { - const command = `git log --format="%s" ${fromRef}...${toRef}`; + const command = `git log --format="{[%B]}" ${fromRef}...${toRef}`; console.log('Getting pull requests merged between the following refs:', fromRef, toRef); console.log('Running command: ', command); const localGitLogs = execSync(command).toString(); + + // Remove the PRs which are duplicated by cherry pick return _.map( - [...localGitLogs.matchAll(/Merge pull request #(\d{1,6}) from (?!Expensify\/(?:master|main|version-))/g)], + [...localGitLogs.matchAll(/{\[Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:[^(\]})]*\(cherry picked from commit .*\)\s*\]}))/g)], match => match[1], ); } From f839e13d4b734b94ecbe6eec618ecca6cdf3e4ee Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Thu, 25 Nov 2021 00:01:13 +0000 Subject: [PATCH 08/15] Use two regexp to parse the pr numbers --- .../createOrUpdateStagingDeploy/index.js | 21 ++++++++++++++++--- .../actions/getDeployPullRequestList/index.js | 21 ++++++++++++++++--- .github/libs/GitUtils.js | 21 ++++++++++++++++--- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index 882f0260eb4c..2f2f0966e0e1 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -200,11 +200,26 @@ function getPullRequestsMergedBetween(fromRef, toRef) { console.log('Running command: ', command); const localGitLogs = execSync(command).toString(); - // Remove the PRs which are duplicated by cherry pick - return _.map( - [...localGitLogs.matchAll(/{\[Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:[^(\]})]*\(cherry picked from commit .*\)\s*\]}))/g)], + // Parse the git log into an array of commit messages between the two refs + const commitMessages = _.map( + [...localGitLogs.matchAll(/{\[([\s\S]*?)\]}/gm)], match => match[1], ); + console.log(`A list of commits made between ${fromRef} and ${toRef}: \n${commitMessages}`); + + // We need to find which commit messages correspond to merge commits and get PR numbers. + // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. + const pullRequestIDs = _.reduce(commitMessages, function(mergedPRs, commitMessage) { + const mergeCommits = [...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm)]; + + // Get the PR number of the first match (there should not be multiple matches in one commit message) + if (_.size(mergeCommits)) { + mergedPRs.push(mergeCommits[0][1]); + }; + return mergedPRs; + }, []); + console.log(`A list of pull requests merged between ${fromRef} and ${toRef}: \n${pullRequestIDs}`); + return pullRequestIDs; } module.exports = { diff --git a/.github/actions/getDeployPullRequestList/index.js b/.github/actions/getDeployPullRequestList/index.js index 925db29f234b..bdf93526e5dd 100644 --- a/.github/actions/getDeployPullRequestList/index.js +++ b/.github/actions/getDeployPullRequestList/index.js @@ -122,11 +122,26 @@ function getPullRequestsMergedBetween(fromRef, toRef) { console.log('Running command: ', command); const localGitLogs = execSync(command).toString(); - // Remove the PRs which are duplicated by cherry pick - return _.map( - [...localGitLogs.matchAll(/{\[Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:[^(\]})]*\(cherry picked from commit .*\)\s*\]}))/g)], + // Parse the git log into an array of commit messages between the two refs + const commitMessages = _.map( + [...localGitLogs.matchAll(/{\[([\s\S]*?)\]}/gm)], match => match[1], ); + console.log(`A list of commits made between ${fromRef} and ${toRef}: \n${commitMessages}`); + + // We need to find which commit messages correspond to merge commits and get PR numbers. + // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. + const pullRequestIDs = _.reduce(commitMessages, function(mergedPRs, commitMessage) { + const mergeCommits = [...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm)]; + + // Get the PR number of the first match (there should not be multiple matches in one commit message) + if (_.size(mergeCommits)) { + mergedPRs.push(mergeCommits[0][1]); + }; + return mergedPRs; + }, []); + console.log(`A list of pull requests merged between ${fromRef} and ${toRef}: \n${pullRequestIDs}`); + return pullRequestIDs; } module.exports = { diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index 04006a705467..377bdf30e0d0 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -14,11 +14,26 @@ function getPullRequestsMergedBetween(fromRef, toRef) { console.log('Running command: ', command); const localGitLogs = execSync(command).toString(); - // Remove the PRs which are duplicated by cherry pick - return _.map( - [...localGitLogs.matchAll(/{\[Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:[^(\]})]*\(cherry picked from commit .*\)\s*\]}))/g)], + // Parse the git log into an array of commit messages between the two refs + const commitMessages = _.map( + [...localGitLogs.matchAll(/{\[([\s\S]*?)\]}/gm)], match => match[1], ); + console.log(`A list of commits made between ${fromRef} and ${toRef}: \n${commitMessages}`); + + // We need to find which commit messages correspond to merge commits and get PR numbers. + // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. + const pullRequestIDs = _.reduce(commitMessages, function(mergedPRs, commitMessage) { + const mergeCommits = [...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm)]; + + // Get the PR number of the first match (there should not be multiple matches in one commit message) + if (_.size(mergeCommits)) { + mergedPRs.push(mergeCommits[0][1]); + }; + return mergedPRs; + }, []); + console.log(`A list of pull requests merged between ${fromRef} and ${toRef}: \n${pullRequestIDs}`); + return pullRequestIDs; } module.exports = { From aa1b13494f0762d08d22484126e39b4cf0fb8ef3 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Thu, 25 Nov 2021 00:01:36 +0000 Subject: [PATCH 09/15] Remove whitespace --- .github/libs/GitUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index 377bdf30e0d0..c31d07319269 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -20,7 +20,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { match => match[1], ); console.log(`A list of commits made between ${fromRef} and ${toRef}: \n${commitMessages}`); - + // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. const pullRequestIDs = _.reduce(commitMessages, function(mergedPRs, commitMessage) { From b1fa8c6e257cb450242d03a6f6078a64119ca617 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Thu, 25 Nov 2021 00:02:05 +0000 Subject: [PATCH 10/15] Build the actions --- .github/actions/createOrUpdateStagingDeploy/index.js | 2 +- .github/actions/getDeployPullRequestList/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index 2f2f0966e0e1..4077abda01b3 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -206,7 +206,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { match => match[1], ); console.log(`A list of commits made between ${fromRef} and ${toRef}: \n${commitMessages}`); - + // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. const pullRequestIDs = _.reduce(commitMessages, function(mergedPRs, commitMessage) { diff --git a/.github/actions/getDeployPullRequestList/index.js b/.github/actions/getDeployPullRequestList/index.js index bdf93526e5dd..ad9e46d70d1b 100644 --- a/.github/actions/getDeployPullRequestList/index.js +++ b/.github/actions/getDeployPullRequestList/index.js @@ -128,7 +128,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { match => match[1], ); console.log(`A list of commits made between ${fromRef} and ${toRef}: \n${commitMessages}`); - + // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. const pullRequestIDs = _.reduce(commitMessages, function(mergedPRs, commitMessage) { From 69a881628e971bde8690be992772a0197fefa850 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Thu, 25 Nov 2021 00:04:05 +0000 Subject: [PATCH 11/15] Use arrow function --- .github/actions/createOrUpdateStagingDeploy/index.js | 4 ++-- .github/actions/getDeployPullRequestList/index.js | 4 ++-- .github/libs/GitUtils.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index 4077abda01b3..fca6eb9ca35a 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -209,13 +209,13 @@ function getPullRequestsMergedBetween(fromRef, toRef) { // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. - const pullRequestIDs = _.reduce(commitMessages, function(mergedPRs, commitMessage) { + const pullRequestIDs = _.reduce(commitMessages, (mergedPRs, commitMessage) => { const mergeCommits = [...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm)]; // Get the PR number of the first match (there should not be multiple matches in one commit message) if (_.size(mergeCommits)) { mergedPRs.push(mergeCommits[0][1]); - }; + } return mergedPRs; }, []); console.log(`A list of pull requests merged between ${fromRef} and ${toRef}: \n${pullRequestIDs}`); diff --git a/.github/actions/getDeployPullRequestList/index.js b/.github/actions/getDeployPullRequestList/index.js index ad9e46d70d1b..18273728ca81 100644 --- a/.github/actions/getDeployPullRequestList/index.js +++ b/.github/actions/getDeployPullRequestList/index.js @@ -131,13 +131,13 @@ function getPullRequestsMergedBetween(fromRef, toRef) { // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. - const pullRequestIDs = _.reduce(commitMessages, function(mergedPRs, commitMessage) { + const pullRequestIDs = _.reduce(commitMessages, (mergedPRs, commitMessage) => { const mergeCommits = [...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm)]; // Get the PR number of the first match (there should not be multiple matches in one commit message) if (_.size(mergeCommits)) { mergedPRs.push(mergeCommits[0][1]); - }; + } return mergedPRs; }, []); console.log(`A list of pull requests merged between ${fromRef} and ${toRef}: \n${pullRequestIDs}`); diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index c31d07319269..4795cd76cbbe 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -23,13 +23,13 @@ function getPullRequestsMergedBetween(fromRef, toRef) { // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. - const pullRequestIDs = _.reduce(commitMessages, function(mergedPRs, commitMessage) { + const pullRequestIDs = _.reduce(commitMessages, (mergedPRs, commitMessage) => { const mergeCommits = [...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm)]; // Get the PR number of the first match (there should not be multiple matches in one commit message) if (_.size(mergeCommits)) { mergedPRs.push(mergeCommits[0][1]); - }; + } return mergedPRs; }, []); console.log(`A list of pull requests merged between ${fromRef} and ${toRef}: \n${pullRequestIDs}`); From 61068451a11d1b0ee99c21ba506106bca632b2b3 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Thu, 25 Nov 2021 00:06:56 +0000 Subject: [PATCH 12/15] Update logs --- .github/actions/createOrUpdateStagingDeploy/index.js | 4 ++-- .github/actions/getDeployPullRequestList/index.js | 4 ++-- .github/libs/GitUtils.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index fca6eb9ca35a..6ab17747bd45 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -205,7 +205,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { [...localGitLogs.matchAll(/{\[([\s\S]*?)\]}/gm)], match => match[1], ); - console.log(`A list of commits made between ${fromRef} and ${toRef}: \n${commitMessages}`); + console.log(`A list of commits made between ${fromRef} and ${toRef}:\n${commitMessages}`); // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. @@ -218,7 +218,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { } return mergedPRs; }, []); - console.log(`A list of pull requests merged between ${fromRef} and ${toRef}: \n${pullRequestIDs}`); + console.log(`A list of pull requests merged between ${fromRef} and ${toRef}:\n${pullRequestIDs}`); return pullRequestIDs; } diff --git a/.github/actions/getDeployPullRequestList/index.js b/.github/actions/getDeployPullRequestList/index.js index 18273728ca81..83be66c54ead 100644 --- a/.github/actions/getDeployPullRequestList/index.js +++ b/.github/actions/getDeployPullRequestList/index.js @@ -127,7 +127,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { [...localGitLogs.matchAll(/{\[([\s\S]*?)\]}/gm)], match => match[1], ); - console.log(`A list of commits made between ${fromRef} and ${toRef}: \n${commitMessages}`); + console.log(`A list of commits made between ${fromRef} and ${toRef}:\n${commitMessages}`); // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. @@ -140,7 +140,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { } return mergedPRs; }, []); - console.log(`A list of pull requests merged between ${fromRef} and ${toRef}: \n${pullRequestIDs}`); + console.log(`A list of pull requests merged between ${fromRef} and ${toRef}:\n${pullRequestIDs}`); return pullRequestIDs; } diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index 4795cd76cbbe..deb99de3ffff 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -19,7 +19,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { [...localGitLogs.matchAll(/{\[([\s\S]*?)\]}/gm)], match => match[1], ); - console.log(`A list of commits made between ${fromRef} and ${toRef}: \n${commitMessages}`); + console.log(`A list of commits made between ${fromRef} and ${toRef}:\n${commitMessages}`); // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. @@ -32,7 +32,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { } return mergedPRs; }, []); - console.log(`A list of pull requests merged between ${fromRef} and ${toRef}: \n${pullRequestIDs}`); + console.log(`A list of pull requests merged between ${fromRef} and ${toRef}:\n${pullRequestIDs}`); return pullRequestIDs; } From 75297341d3da315de8d34af9c44ab3eba4a4cbd8 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Thu, 25 Nov 2021 00:13:48 +0000 Subject: [PATCH 13/15] Adjust the array to not overdo the max char per line limit --- .github/libs/GitUtils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index deb99de3ffff..51cd5e447c0a 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -24,7 +24,9 @@ function getPullRequestsMergedBetween(fromRef, toRef) { // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. const pullRequestIDs = _.reduce(commitMessages, (mergedPRs, commitMessage) => { - const mergeCommits = [...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm)]; + const mergeCommits = [ + ...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm) + ]; // Get the PR number of the first match (there should not be multiple matches in one commit message) if (_.size(mergeCommits)) { From c94553e355462179d70feb13ab6c35be9f8b0207 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Thu, 25 Nov 2021 00:14:51 +0000 Subject: [PATCH 14/15] Build the actions --- .github/actions/createOrUpdateStagingDeploy/index.js | 4 +++- .github/actions/getDeployPullRequestList/index.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index 6ab17747bd45..80b58b90ff63 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -210,7 +210,9 @@ function getPullRequestsMergedBetween(fromRef, toRef) { // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. const pullRequestIDs = _.reduce(commitMessages, (mergedPRs, commitMessage) => { - const mergeCommits = [...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm)]; + const mergeCommits = [ + ...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm) + ]; // Get the PR number of the first match (there should not be multiple matches in one commit message) if (_.size(mergeCommits)) { diff --git a/.github/actions/getDeployPullRequestList/index.js b/.github/actions/getDeployPullRequestList/index.js index 83be66c54ead..d0da487ad9d0 100644 --- a/.github/actions/getDeployPullRequestList/index.js +++ b/.github/actions/getDeployPullRequestList/index.js @@ -132,7 +132,9 @@ function getPullRequestsMergedBetween(fromRef, toRef) { // We need to find which commit messages correspond to merge commits and get PR numbers. // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. const pullRequestIDs = _.reduce(commitMessages, (mergedPRs, commitMessage) => { - const mergeCommits = [...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm)]; + const mergeCommits = [ + ...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm) + ]; // Get the PR number of the first match (there should not be multiple matches in one commit message) if (_.size(mergeCommits)) { From 3c6d0dd9dff96abec29658c94b57e80b24d0eb33 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Thu, 25 Nov 2021 00:22:00 +0000 Subject: [PATCH 15/15] Fix linter --- .github/actions/createOrUpdateStagingDeploy/index.js | 2 +- .github/actions/getDeployPullRequestList/index.js | 2 +- .github/libs/GitUtils.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index 80b58b90ff63..a73d9abeec88 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -211,7 +211,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. const pullRequestIDs = _.reduce(commitMessages, (mergedPRs, commitMessage) => { const mergeCommits = [ - ...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm) + ...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm), ]; // Get the PR number of the first match (there should not be multiple matches in one commit message) diff --git a/.github/actions/getDeployPullRequestList/index.js b/.github/actions/getDeployPullRequestList/index.js index d0da487ad9d0..fa25492fcfc2 100644 --- a/.github/actions/getDeployPullRequestList/index.js +++ b/.github/actions/getDeployPullRequestList/index.js @@ -133,7 +133,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. const pullRequestIDs = _.reduce(commitMessages, (mergedPRs, commitMessage) => { const mergeCommits = [ - ...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm) + ...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm), ]; // Get the PR number of the first match (there should not be multiple matches in one commit message) diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index 51cd5e447c0a..194401ed9238 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -25,7 +25,7 @@ function getPullRequestsMergedBetween(fromRef, toRef) { // Additionally, we omit merge commits made while cherry picking using negative lookahead in the regexp. const pullRequestIDs = _.reduce(commitMessages, (mergedPRs, commitMessage) => { const mergeCommits = [ - ...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm) + ...commitMessage.matchAll(/Merge pull request #(\d{1,6}) from (?!(?:Expensify\/(?:master|main|version-))|(?:([\s\S]*?)\(cherry picked from commit .*\)\s*))/gm), ]; // Get the PR number of the first match (there should not be multiple matches in one commit message)