Fix pre-commit dependency group update-types rules issue#15289
Fix pre-commit dependency group update-types rules issue#15289AbhishekBhaskar wants to merge 22 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a mismatch between grouped and ungrouped update paths when update-types rules are used for ecosystems (notably pre-commit) where dependency.version can be a pinned git SHA, by falling back to the update checker’s resolved comparable current version.
Changes:
- Update
semver_rules_allow_grouping?to use a comparable “current version” (fallback tochecker.current_version) whendependency.versionisn’t semver-comparable. - Expose
Dependabot::UpdateCheckers::Base#current_versionpublicly (and adjustpre-commit’s override visibility) so the updater can call it. - Add specs covering the SHA-pinned fallback behavior.
Show a summary per file
| File | Description |
|---|---|
| updater/lib/dependabot/updater/group_update_creation.rb | Uses a comparable “current version” (with fallback) for update-types semver grouping decisions. |
| common/lib/dependabot/update_checkers/base.rb | Makes current_version publicly available and explicitly overridable for updater usage. |
| pre_commit/lib/dependabot/pre_commit/update_checker.rb | Ensures current_version override remains public and accessible (moves it above private). |
| updater/spec/dependabot/updater/group_update_creation_spec.rb | Adds unit coverage for semver grouping behavior when dependency.version is a SHA. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 3
| ) | ||
| .returns(T.nilable(Dependabot::Version)) | ||
| end | ||
| def comparable_current_version(version_class, dependency, checker) |
There was a problem hiding this comment.
The 7.3.0 → 7.3.0 case (only the commit SHA changed, no semver bump) will not be included in the group — and this is correct behavior.
In semver_rules_allow_grouping?, when current and latest versions are both 7.3.0, none of the segment comparisons trigger (major, minor, patch are all equal), so the method returns false. This means the dependency doesn't match any update-types rule (major, minor, or patch).
However, the update isn't lost — the ungrouped fallback path still picks it up and creates an individual PR (exactly what we saw in the original issue logs: flake8, from 7.3.0 to 7.3.0). This behavior is unchanged by this PR.
If a user wanted to include such "same-version SHA refreshes" in the group, they'd need to use a patterns rule without update-types:
groups:
pre-commit-all:
patterns:
- "*"There was a problem hiding this comment.
@AbhishekBhaskar To call this expected behaviour, we need supporting documentation. The question is: where is that evidence?
|
Is Dependabot grouping supported for the Based on the documentation, there is no answer — especially for GitHub Actions. GitHub Actions use tag or SHA pinning, not manifest/lockfile semantics, so it’s unclear how semver‑based grouping would even apply when updates are driven by commit SHAs. We need to find explicit documentation evidence confirming whether grouping is supported or intentionally excluded. |
|
@thavaahariharangit grouping with The key difference from
Since the This PR's fallback only activates when |
|
@AbhishekBhaskar Is there any Dependabot documentation that explains how semver grouping is handled for commit‑SHA? When we review a PR, we evaluate it on three fronts: For the first point, I need concrete documentation that proves this behaviour is actually expected. |

What are you trying to accomplish?
Fixes #15266.
When a
pre-commitdependency group usesupdate-typesrules (e.g.minor/patch), the grouped update path logged "Nothing to update for Dependency Group" and then fell back to opening separate ungrouped PRs — so the grouped and ungrouped paths disagreed about whether updates existed.The root cause is in
semver_rules_allow_grouping?inupdater/lib/dependabot/updater/group_update_creation.rb. It compared the rawdependency.version, which for pre-commit is a pinned git SHA (e.g.c6755bb…).version_class.correct?(sha)returnsfalse, so the method returnedfalseand silently dropped every dependency from the group. The ungrouped path never applies that filter, so it still raised individual PRs.The fix makes
semver_rules_allow_grouping?fall back to the checker's resolvedcurrent_version(which pre-commit derives from the# frozen:version comment / tag, e.g.26.3.1) whendependency.versionis not a comparable semver. This also benefits any other SHA-pinned ecosystem (e.g.github_actions) usingupdate-typesgroups.Anything you want to highlight for special attention from reviewers?
current_versionwasprivateonDependabot::UpdateCheckers::Base. I moved it to the public section (mirroring the already-publiclatest_version) so the updater can call it, and moved pre-commit'scurrent_versionoverride above itsprivatekeyword.dependency.versionisn't valid semver, so behavior for normal numeric-versioned ecosystems is unchanged.How will you know you've accomplished your goal?
If the above linked issue is fixed and all existing and newly added specs pass.
Checklist