Skip to content

Conversation

@ppkarwasz
Copy link

@ppkarwasz ppkarwasz commented Jun 23, 2025

Dependabot PRs that update a single dependency include version details in the commit message introduction, e.g.,

"Bumps <dependency> from <prevVersion> to <newVersion>."

This is the format generated by the commit_message_intro method in Dependabot Core.

However, when multiple dependencies are updated in a single PR, this format isn't used, which limits the action’s ability to extract accurate version information.

This change improves version parsing for multi-dependency PRs by introducing two additional detection strategies:

  1. YAML metadata parsing Dependabot includes a YAML block in the commit message with structured details for each updated dependency:

    updated-dependencies:
    - dependency-name: commons-codec:commons-codec
      dependency-version: 1.18.0
      dependency-type: direct:production
      update-type: version-update:semver-minor
      dependency-group: non-breaking

    This is the most reliable and stable source for the new version of each dependency, though it does not include the previous version.

  2. Metadata links parsing In multi-dependency updates, Dependabot also appends “metadata links” with a format like:

    "Updates <dependencyName> from <prevVersion> to <newVersion>"

    These lines are generated bythe metadata_links method and provide both the old and new versions.

By combining these sources, the action now supports version parsing for PRs with multiple updated dependencies—broadening its coverage and improving reliability.

Closes #402

Dependabot PRs that update a **single** dependency include version details in the commit message introduction, e.g.,
> "Bumps `<dependency>` from `<prevVersion>` to `<newVersion>`"
This is the format generated by the [`commit_message_intro`](https://github.com/dependabot/dependabot-core/blob/cc4b4eaade37da0a19e0897e6897bab613064e74/common/lib/dependabot/pull_request_creator/message_builder.rb#L320-L325) method in Dependabot Core.

However, when **multiple dependencies** are updated in a single PR, this format isn't used consistently, which limits the action’s ability to extract accurate version information.

This change improves version parsing for multi-dependency PRs by introducing two additional detection strategies:

1. **YAML metadata parsing**
   Dependabot includes a YAML block in the commit message with structured details for each updated dependency:
   ```yaml
   updated-dependencies:
   - dependency-name: commons-codec:commons-codec
     dependency-version: 1.18.0
     dependency-type: direct:production
     update-type: version-update:semver-minor
     dependency-group: non-breaking
   ```
   This is the most reliable and stable source for the **new** version of each dependency, though it does **not** include the previous version.

2. **Metadata links parsing**
   In multi-dependency updates, Dependabot also appends “metadata links” with a format like:
   > "Updates `<dependencyName>` from `<prevVersion>` to `<newVersion>`"
     These lines are generated bythe [`metadata_links`](https://github.com/dependabot/dependabot-core/blob/cc4b4eaade37da0a19e0897e6897bab613064e74/common/lib/dependabot/pull_request_creator/message_builder.rb#L664-L678) method and provide **both** the old and new versions.

By combining these sources, the action now supports version parsing for PRs with multiple updated dependencies—broadening its coverage and improving reliability.

Closes dependabot#402
@ppkarwasz ppkarwasz requested a review from a team as a code owner June 23, 2025 21:50
jeffwidman
jeffwidman previously approved these changes Jul 1, 2025
Copy link
Member

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

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

This looks good to me, other than not understanding the comment syntax?

I'd appreciate if @JamieMagee took a quick look as well since he worked on exposing some of this metadata as he may be aware of some additional context

@ppkarwasz
Copy link
Author

Hi @jeffwidman,

Just a gentle reminder about this PR. Since we switched to compulsory reviews, handling Dependabot PRs (which previously merged automatically with changelog entries) has become more time-consuming. This change (along with apache/logging-parent#419) is part of the approach we devised to streamline things by grouping updates and reviewing them as a single PR.

Would you have an idea when this might be merged and included in a release?

Thanks!

@tekumara
Copy link

tekumara commented Oct 6, 2025

Very much looking forward to this, thank you @ppkarwasz

@ppkarwasz ppkarwasz requested a review from jeffwidman October 6, 2025 07:22
* See `Dependabot::PullRequestCreator::MessageBuilder#metadata_links` in the Ruby codebase for more details
* on the current format.
*
* **NOTE**: This data is only available if more than one dependency is updated in a single PR.

Choose a reason for hiding this comment

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

fyi, here's an example of a grouped update with 1 update - i think this would match here (contrary to the comment)?

Copy link
Author

Choose a reason for hiding this comment

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

You are right grouped PRs with a single updated dependency also contain this data, so I should amend the comment.

The exact generating logic is here.

ppkarwasz added a commit to ppkarwasz/infrastructure-actions that referenced this pull request Oct 26, 2025
…etadata`

This PR allows the usage of the `ppkarwasz/fetch-metadata` GitHub Action as an alternative to `dependabot/fetch-metadata` in ASF repositories.

The `ppkarwasz/fetch-metadata` action is a personal improvement of the original `dependabot/fetch-metadata`, adding support for grouped Dependabot pull requests, a feature that is currently missing from the upstream action. The implementation has already been reviewed and approved by the Dependabot team (see dependabot/fetch-metadata#632), but the upstream project has been inactive for several months, likely due to reduced maintenance capacity at GitHub. This has prevented the improvement from being merged and released.

### Why this change is needed

In Apache Logging Services, every pull request must include a changelog entry. Previously, under CTR, we used a workflow that automatically added the changelog entry and merged the PR.

Since switching to RTC, this automation can no longer complete the merge step, resulting in repositories accumulating unmerged Dependabot PRs that must be:

* manually reviewed,
* updated with an empty commit to re-trigger required status checks,
* and merged by hand.

We already have an improved workflow in place (see apache/logging-parent#419) that provides:

* **Security enhancements** through separation of privileged and unprivileged workflows
  (`ppkarwasz/fetch-metadata` is used only in the unprivileged workflow),
* **Automatic merge using `auto-merge` instead of manual merging**, and
* **Support for grouped Dependabot PRs** (reducing noise to ~1 PR per repository per month).

The final item, grouped PR support, requires the `ppkarwasz/fetch-metadata` action.
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.

Support newVersion and prevVersion for updates with multiple dependencies

4 participants