Commit 1f8753ab56 for woocommerce
commit 1f8753ab56664adcdbb50df506b4293b646837bf
Author: Darren Ethier <darren@roughsmootheng.in>
Date: Fri Feb 13 14:21:09 2026 -0500
Fix changelog significance regex to accept LF-only line endings (#63279)
The getChangelogSignificance() regex required \r\n (CRLF) line endings,
which fails when PR bodies are set via gh CLI or the GitHub API PATCH
endpoint since those produce \n (LF) line endings. Changed \r\n to \r?\n
to accept both formats. Added tests with LF-only bodies.
diff --git a/tools/monorepo-utils/src/changefile/lib/__tests__/github.ts b/tools/monorepo-utils/src/changefile/lib/__tests__/github.ts
index 0688ad33b5..b61ba3bbc9 100644
--- a/tools/monorepo-utils/src/changefile/lib/__tests__/github.ts
+++ b/tools/monorepo-utils/src/changefile/lib/__tests__/github.ts
@@ -231,6 +231,48 @@ describe( 'getChangelogSignificance', () => {
);
} );
+ it( 'should return the selected significance with LF-only line endings', () => {
+ const body =
+ '### Changelog entry\n' +
+ '\n' +
+ '<!-- You can optionally choose to enter a changelog entry by checking the box and supplying data. -->\n' +
+ '\n' +
+ '- [x] Automatically create a changelog entry from the details below.\n' +
+ '\n' +
+ '<details>\n' +
+ '\n' +
+ '#### Significance\n' +
+ '<!-- Choose only one -->\n' +
+ '- [ ] Patch\n' +
+ '- [x] Minor\n' +
+ '- [ ] Major\n' +
+ '\n' +
+ '#### Type\n' +
+ '<!-- Choose only one -->\n' +
+ '- [x] Fix - Fixes an existing bug\n' +
+ '- [ ] Add - Adds functionality\n' +
+ '- [ ] Update - Update existing functionality\n' +
+ '- [ ] Dev - Development related task\n' +
+ '- [ ] Tweak - A minor adjustment to the codebase\n' +
+ '- [ ] Performance - Address performance issues\n' +
+ '- [ ] Enhancement\n' +
+ '\n' +
+ '#### Message ' +
+ '<!-- Add a changelog message here -->\n' +
+ 'This is a very useful fix.\n' +
+ '</details>\n' +
+ '<details>\n' +
+ '<summary>Changelog Entry Comment</summary>' +
+ '\n' +
+ '#### Comment ' +
+ `<!-- If the changes in this pull request don't warrant a changelog entry, you can alternatively supply a comment here. Note that comments are only accepted with a significance of "Patch" -->\n` +
+ '\n' +
+ '</details>';
+
+ const significance = getChangelogSignificance( body );
+ expect( significance ).toBe( 'minor' );
+ } );
+
it( 'should error when more than one significance selected', () => {
const body =
'### Changelog entry\r\n' +
@@ -639,6 +681,51 @@ describe( 'getChangelogDetails', () => {
expect( details.significance ).toEqual( 'minor' );
} );
+ it( 'should return the changelog details with LF-only line endings', () => {
+ const body =
+ '### Changelog entry\n' +
+ '\n' +
+ '<!-- You can optionally choose to enter a changelog entry by checking the box and supplying data. -->\n' +
+ '\n' +
+ '- [x] Automatically create a changelog entry from the details below.\n' +
+ '- [ ] This Pull Request does not require a changelog entry. (Comment required below)\n' +
+ '\n' +
+ '<details>\n' +
+ '\n' +
+ '#### Significance\n' +
+ '<!-- Choose only one -->\n' +
+ '- [x] Patch\n' +
+ '- [ ] Minor\n' +
+ '- [ ] Major\n' +
+ '\n' +
+ '#### Type\n' +
+ '<!-- Choose only one -->\n' +
+ '- [x] Fix - Fixes an existing bug\n' +
+ '- [ ] Add - Adds functionality\n' +
+ '- [ ] Update - Update existing functionality\n' +
+ '- [ ] Dev - Development related task\n' +
+ '- [ ] Tweak - A minor adjustment to the codebase\n' +
+ '- [ ] Performance - Address performance issues\n' +
+ '- [ ] Enhancement\n' +
+ '\n' +
+ '#### Message ' +
+ '<!-- Add a changelog message here -->\n' +
+ 'This is a very useful fix.\n' +
+ '</details>\n' +
+ '<details>\n' +
+ '<summary>Changelog Entry Comment</summary>' +
+ '\n' +
+ '#### Comment <!-- A comment explaining why there is no changelog --> ' +
+ '\n' +
+ '</details>';
+
+ const details = getChangelogDetails( body );
+ expect( details.significance ).toEqual( 'patch' );
+ expect( details.type ).toEqual( 'fix' );
+ expect( details.message ).toEqual( 'This is a very useful fix.' );
+ expect( details.comment ).toEqual( '' );
+ } );
+
it( 'should return details when no changelog required is checked', () => {
const body =
'### Changelog entry\r\n' +
diff --git a/tools/monorepo-utils/src/changefile/lib/github.ts b/tools/monorepo-utils/src/changefile/lib/github.ts
index 52e571efcb..85a9df0f5a 100644
--- a/tools/monorepo-utils/src/changefile/lib/github.ts
+++ b/tools/monorepo-utils/src/changefile/lib/github.ts
@@ -68,7 +68,7 @@ export const shouldAutomateNoChangelog = ( body: string ) => {
* @return {void|string} changelog significance.
*/
export const getChangelogSignificance = ( body: string ) => {
- const regex = /\[(?:x|X)\] (Patch|Minor|Major)\r\n/gm;
+ const regex = /\[(?:x|X)\] (Patch|Minor|Major)\r?\n/gm;
const matches = body.match( regex );
if ( matches === null ) {