Files
Mike Ryan 525f80d6df fix(package-rules): respect each dep update's fetchChangeLogs value (#42671)
* fix(package-rules): respect each dep update's fetchChangeLogs value

Ensures that changelog fetching respects each dep update's specific `fetchChangeLogs` value.

Given the following renovate configuration: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/blob/fb9e070d0f9a4d6fc742c4a22edee2c9b055fece/.github/renovate.json5#L42-L61

My expectation is that Renovate would never fetch changelogs for `lodash`. However, when grouped
together with `chalk` and `tar` under `group of unrelated packages`, we find that
renovate fetches changelogs all packages, including `lodash`.

Before this change (`lodash` logs fetched):
- Run: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/actions/runs/24480887343/job/71544876893
- (wrong) lodash, tar, and chalk all have changelogs: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/pull/9

After this change, the PR created by renovate only contains changelogs for `chalk` and `tar`, but not `lodash`:

- Run: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/actions/runs/24481738609/job/71547632550
- (expected) lodash does not have changelogs, but tar and chalk have changelogs: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/pull/10

----

We can further explore the effectiveness of the change with a more elaborate configuration, where the top-level has `fetchChangeLogs: off`: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/blob/0ea69c18b9171e38c56440c762faa68109d3d0d5/.github/renovate.json5#L41-L95

Before the change:

- Run: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/actions/runs/24482213234/job/71549162174
- (wrong) lodash, tar, and chalk all have changelogs: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/pull/15
- (expected) typescript (inherited `off`) does not have changelogs: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/pull/17
- (expected) grunt (overridden `pr`) has changelogs: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/pull/13

After the change::

- Run: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/actions/runs/24482561172/job/71550255278
- (expected) lodash does not have changelogs, but tar and chalk have changelogs: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/pull/22
- (expected) typescript (inherited `off`) does not have changelogs: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/pull/24
- (expected) grunt (overridden `pr`) has changelogs: https://github.com/justfalter/renovate-test-packagerules-fetchchangelogs/pull/20

Portions of this PR previously appeared in #42368

* pre feedback: just use fetchChangeLogs from upgrade

* revert documentation.spec.ts changes

They've already been integrated with #42846
2026-04-27 15:28:15 +00:00

57 lines
1.6 KiB
TypeScript

import * as p from '../../../util/promises.ts';
import type { BranchUpgradeConfig } from '../../types.ts';
import { getChangeLogJSON } from '../update/pr/changelog/index.ts';
import type { EmbedChangelogsOptions } from './types.ts';
export async function embedChangelog(
upgrade: BranchUpgradeConfig,
): Promise<void> {
// getChangeLogJSON returns null on error, so don't try again
if (upgrade.logJSON !== undefined) {
return;
}
if (upgrade.changelogContent === undefined) {
upgrade.logJSON = await getChangeLogJSON(upgrade);
} else {
upgrade.logJSON = {
hasReleaseNotes: true,
project: {
packageName: upgrade.packageName,
depName: upgrade.depName,
type: undefined!,
apiBaseUrl: undefined!,
baseUrl: undefined!,
repository: upgrade.repository!,
sourceUrl: upgrade.sourceUrl!,
sourceDirectory: upgrade.sourceDirectory,
},
versions: [
{
changes: undefined!,
compare: undefined!,
date: undefined!,
releaseNotes: {
body: upgrade.changelogContent,
notesSourceUrl: undefined!,
url: upgrade.changelogUrl!,
},
gitRef: undefined!,
version: upgrade.newVersion!,
},
],
};
}
}
export async function embedChangelogs({
upgrades,
stage,
}: EmbedChangelogsOptions): Promise<void> {
// Only process upgrades whose fetchChangeLogs value match the stage.
const filteredUpgrades = upgrades.filter(
(upgrade) => upgrade.fetchChangeLogs === stage,
);
await p.map(filteredUpgrades, embedChangelog, { concurrency: 10 });
}