Skip to content

fix(package-rules): respect each dep update's fetchChangeLogs value#42671

Open
justfalter wants to merge 1 commit intorenovatebot:mainfrom
justfalter:fix-packagerule-fetchchangelogs
Open

fix(package-rules): respect each dep update's fetchChangeLogs value#42671
justfalter wants to merge 1 commit intorenovatebot:mainfrom
justfalter:fix-packagerule-fetchchangelogs

Conversation

@justfalter
Copy link
Copy Markdown
Contributor

@justfalter justfalter commented Apr 15, 2026

Changes

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

  "packageRules": [
    {
      "matchPackageNames": [
        "lodash"
      ],
      "prBodyNotes": [
        "* lodash - should have no changelogs"
      ],
      "fetchChangeLogs": "off"
    },
    {
      // PROBLEM: the grouping of "lodash" with chalk and tar causes its fetchChangeLogs to not be respected
      "matchPackageNames": [
        "lodash",
        "chalk",
        "tar"
      ],
      "groupName": "group of unrelated packages"
    }
  ]

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 for all packages, including lodash.

Before this change (lodash logs fetched):

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


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

  "fetchChangeLogs": "off",
  "packageRules": [
    {
      "matchPackageNames": [
        "typescript"
      ],
      "prBodyNotes": [
        "* typescript - inherits fetchChangeLogs from base config"
      ],
    },
    {
      "matchPackageNames": [
        "grunt"
      ],
      "prBodyNotes": [
        "* grunt - fetches change logs"
      ],
      "fetchChangeLogs": "pr"
    },
    {
      "matchPackageNames": [
        "chalk"
      ],
      "prBodyNotes": [
        "* chalk - should have changelogs"
      ],
      "fetchChangeLogs": "pr"
    },
    {
      "matchPackageNames": [
        "tar"
      ],
      "prBodyNotes": [
        "* tar - should have changelogs"
      ],
      "fetchChangeLogs": "pr"
    },
    {
      "matchPackageNames": [
        "lodash"
      ],
      "prBodyNotes": [
        "* lodash - should have no changelogs"
      ],
      "fetchChangeLogs": "off"
    },
    {
      // PROBLEM: the grouping of "lodash" with chalk and tar causes its fetchChangeLogs to not be respected
      "matchPackageNames": [
        "lodash",
        "chalk",
        "tar"
      ],
      "groupName": "group of unrelated packages"
    }

Before the change:

After the change::

Portions of this PR previously appeared in #42368

Context

Please select one of the following:

  • This closes an existing Issue, Closes: #
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests, but ran on a real repository, or
  • Both unit tests + ran on a real repository

The public repository:

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: justfalter/renovate-test-packagerules-fetchchangelogs#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: justfalter/renovate-test-packagerules-fetchchangelogs#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: justfalter/renovate-test-packagerules-fetchchangelogs#15
- (expected) typescript (inherited `off`) does not have changelogs: justfalter/renovate-test-packagerules-fetchchangelogs#17
- (expected) grunt (overridden `pr`) has changelogs: justfalter/renovate-test-packagerules-fetchchangelogs#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: justfalter/renovate-test-packagerules-fetchchangelogs#22
- (expected) typescript (inherited `off`) does not have changelogs: justfalter/renovate-test-packagerules-fetchchangelogs#24
- (expected) grunt (overridden `pr`) has changelogs: justfalter/renovate-test-packagerules-fetchchangelogs#20

Portions of this PR previously appeared in renovatebot#42368
@justfalter
Copy link
Copy Markdown
Contributor Author

It felt cleaner to just create a new pull request --- I believe that I've addressed all the feedback provided in #42368 (including request viceice's request for some more elaborate testing).

Comment on lines +49 to +60
function resolveFetchChangeLogs(
fetchChangeLogs?: FetchChangeLogsOptions,
upgradeFetchChangeLogs?: FetchChangeLogsOptions,
): FetchChangeLogsOptions {
// Default to 'pr' if top-level fetchChangeLogs is undefined.
let fetchChangeLogsResolved: FetchChangeLogsOptions = fetchChangeLogs ?? 'pr';
if (upgradeFetchChangeLogs) {
// Override using the upgrade's fetchChangeLogs value.
fetchChangeLogsResolved = upgradeFetchChangeLogs;
}
return fetchChangeLogsResolved;
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree with viceice's comment from from my old PR that an upgrade will probably always have fetchChangeLogs set, but the underlying types have them as optional. I feel like this resolve function is a good compromise for avoiding having to delve deep into renovate's types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant