From e1e5f7f7d09e5bb7f2be6861fa3a6f9855331db5 Mon Sep 17 00:00:00 2001
From: IKEDA Sho <suicaicoca@gmail.com>
Date: Wed, 17 May 2023 00:31:42 +0900
Subject: [PATCH] fix(changelog): correct excactReleaseRegex (#22265)

---
 .../update/pr/changelog/github.spec.ts        | 19 ++++++++++++++++++-
 .../update/pr/changelog/source-github.ts      |  2 +-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/lib/workers/repository/update/pr/changelog/github.spec.ts b/lib/workers/repository/update/pr/changelog/github.spec.ts
index 8571c68460..ee6fe19cee 100644
--- a/lib/workers/repository/update/pr/changelog/github.spec.ts
+++ b/lib/workers/repository/update/pr/changelog/github.spec.ts
@@ -366,6 +366,10 @@ describe('workers/repository/update/pr/changelog/github', () => {
           { version: '1.0.1' },
           { version: 'correctPrefix/target@1.0.1' },
           { version: 'wrongPrefix/target-1.0.1' },
+          { version: 'v1.0.2' },
+          { version: '1.0.2' },
+          { version: 'correctPrefix/target-1.0.2' },
+          { version: 'wrongPrefix/target@1.0.2' },
         ])
       );
 
@@ -376,9 +380,10 @@ describe('workers/repository/update/pr/changelog/github', () => {
         endpoint: 'https://api.github.com/',
         versioning: 'npm',
         currentVersion: '1.0.0',
-        newVersion: '1.0.1',
+        newVersion: '1.0.2',
         sourceUrl: 'https://github.com/chalk/chalk',
         releases: [
+          { version: '1.0.2', gitRef: '789012' },
           { version: '1.0.1', gitRef: '123456' },
           { version: '0.1.1', gitRef: 'npm_1.0.0' },
         ],
@@ -398,6 +403,18 @@ describe('workers/repository/update/pr/changelog/github', () => {
           packageName: 'correctPrefix/target',
         },
         versions: [
+          {
+            version: '1.0.2',
+            date: undefined,
+            changes: [],
+            compare: {
+              url: 'https://github.com/chalk/chalk/compare/correctPrefix/target@1.0.1...correctPrefix/target-1.0.2',
+            },
+            releaseNotes: {
+              url: 'https://github.com/chalk/chalk/compare/correctPrefix/target@1.0.1...correctPrefix/target-1.0.2',
+              notesSourceUrl: '',
+            },
+          },
           {
             version: '1.0.1',
             date: undefined,
diff --git a/lib/workers/repository/update/pr/changelog/source-github.ts b/lib/workers/repository/update/pr/changelog/source-github.ts
index 19ed0f561d..9b7bc2922b 100644
--- a/lib/workers/repository/update/pr/changelog/source-github.ts
+++ b/lib/workers/repository/update/pr/changelog/source-github.ts
@@ -195,7 +195,7 @@ function findTagOfRelease(
   tags: string[]
 ): string | undefined {
   const regex = regEx(`(?:${packageName}|release)[@-]`, undefined, false);
-  const excactReleaseRegex = regEx(`${packageName}[@-_]v?${depNewVersion}`);
+  const excactReleaseRegex = regEx(`${packageName}[@\\-_]v?${depNewVersion}`);
   const exactTagsList = tags.filter((tag) => {
     return excactReleaseRegex.test(tag);
   });
-- 
GitLab