diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index a6524bcf7d17..c7a84ad922c9 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -218,38 +218,45 @@ const CONST = __nccwpck_require__(4097); const sanitizeStringForJSONParse = __nccwpck_require__(9338); /** - * @param {String} ref + * @param {String} tag */ -function fetchRefIfNeeded(ref) { +function fetchTagIfNeeded(tag) { try { - console.log(`Checking if ref ${ref} exists locally`); - const command = `git rev-parse --verify ${ref}`; + console.log(`Checking if tag ${tag} exists locally`); + const command = `git rev-parse --verify ${tag}`; console.log(`Running command: ${command}`); - execSync(command); + const result = execSync(command).toString(); + console.log(result); } catch (e) { - console.log(`Ref ${ref} not found locally, attempting to fetch it.`); - const command = `git fetch origin ${ref}`; + console.log(`Tag ${tag} not found locally, attempting to fetch it.`); + let command = `git fetch origin refs/tags/${tag}:refs/tags/${tag}`; console.log(`Running command: ${command}`); - execSync(command); + let result = execSync(command).toString(); + console.log(result); + console.log('Verifying that the tag is now available...'); + command = `git rev-parse --verify ${tag}`; + console.log(`Running command: ${command}`); + result = execSync(command).toString(); + console.log(result); } } /** - * Get merge logs between two refs (inclusive) as a JavaScript object. + * Get merge logs between two tags (inclusive) as a JavaScript object. * - * @param {String} fromRef - * @param {String} toRef + * @param {String} fromTag + * @param {String} toTag * @returns {Promise>>} */ -function getCommitHistoryAsJSON(fromRef, toRef) { - fetchRefIfNeeded(fromRef); - fetchRefIfNeeded(toRef); +function getCommitHistoryAsJSON(fromTag, toTag) { + fetchTagIfNeeded(fromTag); + fetchTagIfNeeded(toTag); - console.log('Getting pull requests merged between the following refs:', fromRef, toRef); + console.log('Getting pull requests merged between the following tags:', fromTag, toTag); return new Promise((resolve, reject) => { let stdout = ''; let stderr = ''; - const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromRef}...${toRef}`]; + const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromTag}...${toTag}`]; console.log(`Running command: git ${args.join(' ')}`); const spawnedProcess = spawn('git', args); spawnedProcess.on('message', console.log); @@ -314,19 +321,19 @@ function getValidMergedPRs(commits) { } /** - * Takes in two git refs and returns a list of PR numbers of all PRs merged between those two refs + * Takes in two git tags and returns a list of PR numbers of all PRs merged between those two tags * - * @param {String} fromRef - * @param {String} toRef + * @param {String} fromTag + * @param {String} toTag * @returns {Promise>} – Pull request numbers */ -function getPullRequestsMergedBetween(fromRef, toRef) { - return getCommitHistoryAsJSON(fromRef, toRef).then((commitList) => { - console.log(`Commits made between ${fromRef} and ${toRef}:`, commitList); +function getPullRequestsMergedBetween(fromTag, toTag) { + return getCommitHistoryAsJSON(fromTag, toTag).then((commitList) => { + console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); // Find which commit messages correspond to merged PR's const pullRequestNumbers = getValidMergedPRs(commitList); - console.log(`List of pull requests merged between ${fromRef} and ${toRef}`, pullRequestNumbers); + console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); return pullRequestNumbers; }); } diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index f46ea055282a..7339beca6d9a 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -152,38 +152,45 @@ const CONST = __nccwpck_require__(4097); const sanitizeStringForJSONParse = __nccwpck_require__(9338); /** - * @param {String} ref + * @param {String} tag */ -function fetchRefIfNeeded(ref) { +function fetchTagIfNeeded(tag) { try { - console.log(`Checking if ref ${ref} exists locally`); - const command = `git rev-parse --verify ${ref}`; + console.log(`Checking if tag ${tag} exists locally`); + const command = `git rev-parse --verify ${tag}`; console.log(`Running command: ${command}`); - execSync(command); + const result = execSync(command).toString(); + console.log(result); } catch (e) { - console.log(`Ref ${ref} not found locally, attempting to fetch it.`); - const command = `git fetch origin ${ref}`; + console.log(`Tag ${tag} not found locally, attempting to fetch it.`); + let command = `git fetch origin refs/tags/${tag}:refs/tags/${tag}`; console.log(`Running command: ${command}`); - execSync(command); + let result = execSync(command).toString(); + console.log(result); + console.log('Verifying that the tag is now available...'); + command = `git rev-parse --verify ${tag}`; + console.log(`Running command: ${command}`); + result = execSync(command).toString(); + console.log(result); } } /** - * Get merge logs between two refs (inclusive) as a JavaScript object. + * Get merge logs between two tags (inclusive) as a JavaScript object. * - * @param {String} fromRef - * @param {String} toRef + * @param {String} fromTag + * @param {String} toTag * @returns {Promise>>} */ -function getCommitHistoryAsJSON(fromRef, toRef) { - fetchRefIfNeeded(fromRef); - fetchRefIfNeeded(toRef); +function getCommitHistoryAsJSON(fromTag, toTag) { + fetchTagIfNeeded(fromTag); + fetchTagIfNeeded(toTag); - console.log('Getting pull requests merged between the following refs:', fromRef, toRef); + console.log('Getting pull requests merged between the following tags:', fromTag, toTag); return new Promise((resolve, reject) => { let stdout = ''; let stderr = ''; - const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromRef}...${toRef}`]; + const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromTag}...${toTag}`]; console.log(`Running command: git ${args.join(' ')}`); const spawnedProcess = spawn('git', args); spawnedProcess.on('message', console.log); @@ -248,19 +255,19 @@ function getValidMergedPRs(commits) { } /** - * Takes in two git refs and returns a list of PR numbers of all PRs merged between those two refs + * Takes in two git tags and returns a list of PR numbers of all PRs merged between those two tags * - * @param {String} fromRef - * @param {String} toRef + * @param {String} fromTag + * @param {String} toTag * @returns {Promise>} – Pull request numbers */ -function getPullRequestsMergedBetween(fromRef, toRef) { - return getCommitHistoryAsJSON(fromRef, toRef).then((commitList) => { - console.log(`Commits made between ${fromRef} and ${toRef}:`, commitList); +function getPullRequestsMergedBetween(fromTag, toTag) { + return getCommitHistoryAsJSON(fromTag, toTag).then((commitList) => { + console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); // Find which commit messages correspond to merged PR's const pullRequestNumbers = getValidMergedPRs(commitList); - console.log(`List of pull requests merged between ${fromRef} and ${toRef}`, pullRequestNumbers); + console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); return pullRequestNumbers; }); } diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index 227fd1bbb538..ebdb08f8a099 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -4,38 +4,45 @@ const CONST = require('./CONST'); const sanitizeStringForJSONParse = require('./sanitizeStringForJSONParse'); /** - * @param {String} ref + * @param {String} tag */ -function fetchRefIfNeeded(ref) { +function fetchTagIfNeeded(tag) { try { - console.log(`Checking if ref ${ref} exists locally`); - const command = `git rev-parse --verify ${ref}`; + console.log(`Checking if tag ${tag} exists locally`); + const command = `git rev-parse --verify ${tag}`; console.log(`Running command: ${command}`); - execSync(command); + const result = execSync(command).toString(); + console.log(result); } catch (e) { - console.log(`Ref ${ref} not found locally, attempting to fetch it.`); - const command = `git fetch origin ${ref}`; + console.log(`Tag ${tag} not found locally, attempting to fetch it.`); + let command = `git fetch origin refs/tags/${tag}:refs/tags/${tag}`; console.log(`Running command: ${command}`); - execSync(command); + let result = execSync(command).toString(); + console.log(result); + console.log('Verifying that the tag is now available...'); + command = `git rev-parse --verify ${tag}`; + console.log(`Running command: ${command}`); + result = execSync(command).toString(); + console.log(result); } } /** - * Get merge logs between two refs (inclusive) as a JavaScript object. + * Get merge logs between two tags (inclusive) as a JavaScript object. * - * @param {String} fromRef - * @param {String} toRef + * @param {String} fromTag + * @param {String} toTag * @returns {Promise>>} */ -function getCommitHistoryAsJSON(fromRef, toRef) { - fetchRefIfNeeded(fromRef); - fetchRefIfNeeded(toRef); +function getCommitHistoryAsJSON(fromTag, toTag) { + fetchTagIfNeeded(fromTag); + fetchTagIfNeeded(toTag); - console.log('Getting pull requests merged between the following refs:', fromRef, toRef); + console.log('Getting pull requests merged between the following tags:', fromTag, toTag); return new Promise((resolve, reject) => { let stdout = ''; let stderr = ''; - const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromRef}...${toRef}`]; + const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromTag}...${toTag}`]; console.log(`Running command: git ${args.join(' ')}`); const spawnedProcess = spawn('git', args); spawnedProcess.on('message', console.log); @@ -100,19 +107,19 @@ function getValidMergedPRs(commits) { } /** - * Takes in two git refs and returns a list of PR numbers of all PRs merged between those two refs + * Takes in two git tags and returns a list of PR numbers of all PRs merged between those two tags * - * @param {String} fromRef - * @param {String} toRef + * @param {String} fromTag + * @param {String} toTag * @returns {Promise>} – Pull request numbers */ -function getPullRequestsMergedBetween(fromRef, toRef) { - return getCommitHistoryAsJSON(fromRef, toRef).then((commitList) => { - console.log(`Commits made between ${fromRef} and ${toRef}:`, commitList); +function getPullRequestsMergedBetween(fromTag, toTag) { + return getCommitHistoryAsJSON(fromTag, toTag).then((commitList) => { + console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); // Find which commit messages correspond to merged PR's const pullRequestNumbers = getValidMergedPRs(commitList); - console.log(`List of pull requests merged between ${fromRef} and ${toRef}`, pullRequestNumbers); + console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); return pullRequestNumbers; }); }