Use Correct PR Numbers In Code Freeze Changelog Command (#40096)

* Fixed Changelog PR Number Markdown

This makes the regex for replacing the number with a
markdown link more strict. Previously it was converting
[#PRNUM] to [[#PRNUM]] and would also add a markdown link
even if one was only present. This solves those two issues.

* Deepen Code Freeze Changelog Checkout

By default our remote branch checkout performs a shallow checkout. This
results in the Jetpack Changelogger appending the wrong PR number
when we generate the changelog for the `readme.txt` file. Here we are
deepening the checkout to resolve the problem.
This commit is contained in:
Christopher Allford 2023-09-12 08:49:03 -07:00 committed by GitHub
parent e52d11a87e
commit deee539245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -54,8 +54,8 @@ const updateReleaseChangelogs = async (
// Convert PR number to markdown link.
nextLog = nextLog.replace(
/\[#(\d+)\]/g,
'[$&](https://github.com/woocommerce/woocommerce/pull/$1)'
/\[#(\d+)\](?!\()/g,
'[#$1](https://github.com/woocommerce/woocommerce/pull/$1)'
);
readme = readme.replace(
@ -81,7 +81,8 @@ export const updateReleaseBranchChangelogs = async (
): Promise< { deletionCommitHash: string; prNumber: number } > => {
const { owner, name, version } = options;
try {
await checkoutRemoteBranch( tmpRepoPath, releaseBranch );
// Do a full checkout so that we can find the correct PR numbers for changelog entries.
await checkoutRemoteBranch( tmpRepoPath, releaseBranch, false );
} catch ( e ) {
if ( e.message.includes( "couldn't find remote ref" ) ) {
Logger.error(