diff --git a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts index 071f42ffe7d89f..f1217f926fd83a 100644 --- a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts +++ b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts @@ -87,20 +87,21 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }); describe('addReleaseNotes()', () => { + it('returns null if input is null/undefined', async () => { + expect(await addReleaseNotes(null, {} as BranchUpgradeConfig)).toBeNull(); + expect( + await addReleaseNotes(undefined, {} as BranchUpgradeConfig) + ).toBeNull(); + }); + it('returns input if invalid', async () => { const input = { a: 1 }; expect( await addReleaseNotes(input as never, {} as BranchUpgradeConfig) ).toEqual(input); - // TODO #7154 + expect(await addReleaseNotes(null, {} as BranchUpgradeConfig)).toBeNull(); expect( - await addReleaseNotes(null as never, {} as BranchUpgradeConfig) - ).toBeNull(); - expect( - await addReleaseNotes( - { versions: [] } as never, - {} as BranchUpgradeConfig - ) + await addReleaseNotes({ versions: [] }, {} as BranchUpgradeConfig) ).toStrictEqual({ versions: [], }); diff --git a/lib/workers/repository/update/pr/changelog/release-notes.ts b/lib/workers/repository/update/pr/changelog/release-notes.ts index 514a46623b1437..31446797c7c0f7 100644 --- a/lib/workers/repository/update/pr/changelog/release-notes.ts +++ b/lib/workers/repository/update/pr/changelog/release-notes.ts @@ -399,14 +399,13 @@ export function releaseNotesCacheMinutes(releaseDate?: string | Date): number { return 14495; // 5 minutes shy of 10 days } -// TODO #7154 allow `null` and `undefined` export async function addReleaseNotes( - input: ChangeLogResult, + input: ChangeLogResult | null | undefined, config: BranchUpgradeConfig -): Promise { +): Promise { if (!input?.versions || !input.project?.type) { logger.debug('Missing project or versions'); - return input; + return input ?? null; } const output: ChangeLogResult = { ...input, versions: [] }; const { repository, sourceDirectory } = input.project; diff --git a/lib/workers/repository/update/pr/changelog/source-github.ts b/lib/workers/repository/update/pr/changelog/source-github.ts index e3302393f5c13d..a3bcb339086f10 100644 --- a/lib/workers/repository/update/pr/changelog/source-github.ts +++ b/lib/workers/repository/update/pr/changelog/source-github.ts @@ -165,7 +165,7 @@ export async function getChangeLogJSON( } } - let res: ChangeLogResult = { + let res: ChangeLogResult | null = { project: { apiBaseUrl, baseUrl, diff --git a/lib/workers/repository/update/pr/changelog/source-gitlab.ts b/lib/workers/repository/update/pr/changelog/source-gitlab.ts index e55b681849df16..4fa2ebe0adf38a 100644 --- a/lib/workers/repository/update/pr/changelog/source-gitlab.ts +++ b/lib/workers/repository/update/pr/changelog/source-gitlab.ts @@ -137,7 +137,7 @@ export async function getChangeLogJSON( } } - let res: ChangeLogResult = { + let res: ChangeLogResult | null = { project: { apiBaseUrl, baseUrl,