[Changefile] Fix Message regex (#48649)

* fix regex

* tests
This commit is contained in:
Paul Sealock 2024-06-20 10:42:40 +12:00 committed by GitHub
parent 61517c2609
commit 0a411dd352
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 41 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -131,6 +131,9 @@ describe( 'getChangelogSignificance', () => {
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\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" -->\r\n` +
@ -170,6 +173,9 @@ describe( 'getChangelogSignificance', () => {
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\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" -->\r\n` +
@ -209,6 +215,9 @@ describe( 'getChangelogSignificance', () => {
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\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" -->\r\n` +
@ -251,6 +260,9 @@ describe( 'getChangelogSignificance', () => {
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\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" -->\r\n` +
@ -295,6 +307,9 @@ describe( 'getChangelogType', () => {
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\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" -->\r\n` +
@ -334,6 +349,9 @@ describe( 'getChangelogType', () => {
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\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" -->\r\n` +
@ -373,6 +391,9 @@ describe( 'getChangelogType', () => {
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\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" -->\r\n` +
@ -415,6 +436,9 @@ describe( 'getChangelogType', () => {
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\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" -->\r\n` +
@ -460,6 +484,9 @@ describe( 'getChangelogDetails', () => {
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\n' +
'#### Comment <!-- a comment explaining why there is no changlog --> ' +
'\r\n' +
@ -502,6 +529,9 @@ describe( 'getChangelogDetails', () => {
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\n' +
'#### Comment <!-- a comment explaining why there is no changlog --> ' +
`<!-- 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" -->\r\n` +
@ -544,6 +574,9 @@ describe( 'getChangelogDetails', () => {
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'I promise!\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\n' +
'#### Comment <!-- a comment explaining why there is no changlog --> ' +
`<!-- 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" -->\r\n` +
@ -591,6 +624,9 @@ describe( 'getChangelogDetails', () => {
'\r\n' +
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\n' +
'#### Comment <!-- a comment explaining why there is no changlog --> ' +
`<!-- 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" -->\r\n` +
@ -633,6 +669,9 @@ describe( 'getChangelogDetails', () => {
'#### Message ' +
'<!-- Add a changelog message here -->\r\n' +
'This is a very useful fix.\r\n' +
'</details>\r\n' +
'<details>\r\n' +
'<summary>Changelog Entry Comment</summary>' +
'\r\n' +
'#### Comment <!-- a comment explaining why there is no changlog --> ' +
`<!-- 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" -->\r\n` +

View File

@ -125,7 +125,7 @@ export const getChangelogType = ( body: string ) => {
* @return {void|string} changelog message.
*/
export const getChangelogMessage = ( body: string ) => {
const messageRegex = /#### Message ?(<!--(.*)-->)?(.*)#### Comment/gms;
const messageRegex = /#### Message ?(<!--(.*?)-->)?(.*?)<\/details>/gms;
const match = messageRegex.exec( body );
if ( ! match ) {