Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(changelog): correct excactReleaseRegex #22265

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/workers/repository/update/pr/changelog/github.spec.ts
Expand Up @@ -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' },
])
);

Expand All @@ -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' },
],
Expand All @@ -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,
Expand Down
Expand Up @@ -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}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const excactReleaseRegex = regEx(`${packageName}[@\\-_]v?${depNewVersion}`);
const excactReleaseRegex = regEx(`${packageName}[@_-]v?${depNewVersion}`);

this would be a simpler solution 😬

const exactTagsList = tags.filter((tag) => {
return excactReleaseRegex.test(tag);
});
Expand Down