diff --git a/lib/workers/repository/update/pr/changelog/bitbucket/index.ts b/lib/workers/repository/update/pr/changelog/bitbucket/index.ts index de54b99b91727f..098a1589669055 100644 --- a/lib/workers/repository/update/pr/changelog/bitbucket/index.ts +++ b/lib/workers/repository/update/pr/changelog/bitbucket/index.ts @@ -1,3 +1,4 @@ +import path from 'node:path'; import is from '@sindresorhus/is'; import changelogFilenameRegex from 'changelog-filename-regex'; import { logger } from '../../../../../../logger'; @@ -44,15 +45,12 @@ export async function getReleaseNotesMd( const allFiles = rootFiles.filter((f) => f.type === 'commit_file'); const files = allFiles.filter((f) => - changelogFilenameRegex.test(getFilenameFromPath(f.path)), + changelogFilenameRegex.test(path.basename(f.path)), ); const changelogFile = files .sort((a, b) => - compareChangelogFilePath( - getFilenameFromPath(a.path), - getFilenameFromPath(b.path), - ), + compareChangelogFilePath(path.basename(a.path), path.basename(b.path)), ) .shift(); if (is.nullOrUndefined(changelogFile)) { @@ -81,10 +79,6 @@ export async function getReleaseNotesMd( return { changelogFile: changelogFile.path, changelogMd }; } -function getFilenameFromPath(filePath: string): string { - return filePath.split('/').pop()!; -} - export function getReleaseList( _project: ChangeLogProject, _release: ChangeLogRelease,