Skip to content

fix(datasource/crate): preserve build metadata #36005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

weihanglo
Copy link

Changes

Add a default extractVersion for cargo manager to remove build metadata,
instead of manual stripp inside CrateDatasource.getReleases.

This is just a proof of concept showing what I found. And sorry I didn't open a discussion first 😞. Feel free to close it.

Context

rust-lang/cargo#15557 (comment)

  • curl-sys's original version is 0.4.80+curl-8.12.1.
  • Renovate has an ad-hoc build-metadata stripping because Cargo doesn't like it.
  • postprocessRelease use the stripped version, which cannot be found because original exact version string is required, such as https://crates.io/crates/curl-sys/0.4.80+curl-8.12.1.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required
  • Maybe required as a new default value of extractVersion is added?

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

@CLAassistant
Copy link

CLAassistant commented May 18, 2025

CLA assistant check
All committers have signed the CLA.

@@ -299,7 +299,7 @@ exports[`modules/datasource/crate/index > getReleases > processes real data: lib
"version": "0.2.50",
},
{
"version": "0.2.51",
"version": "0.2.51+metadata",
Copy link
Author

Choose a reason for hiding this comment

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

I believe the build metadata will eventually go through applyDatasourceFilters, so should be fine here.

(though I haven't found a place to test this)

@rarkins rarkins requested a review from zharinov May 18, 2025 07:07
@viceice viceice changed the title fix: preserve build metadata as crates.io needs the original version fix(datasource/crate): preserve build metadata May 22, 2025
@@ -110,7 +110,7 @@ export class CrateDatasource extends Datasource {
result.releases = lines
.map((version) => {
const release: Release = {
version: version.vers.replace(/\+.*$/, ''),
version: version.vers,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
version: version.vers,
version: version.replace(/\+.*$/, ''),
versionOrig: version.vers,

maybe we should better use gitRef here? 🤔

Copy link
Author

Choose a reason for hiding this comment

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

Hmm... but the version string here has nothing to do with git.

@rarkins rarkins requested a review from viceice May 24, 2025 09:05
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

@weihanglo can you please sign the cla?

@rarkins are you fine with this solution / workaround?

otherwise LGTM

@weihanglo
Copy link
Author

Signed. Thank you!

rarkins
rarkins previously approved these changes May 25, 2025
Co-authored-by: Michael Kriese <[email protected]>
viceice
viceice previously approved these changes May 26, 2025
@weihanglo
Copy link
Author

Just fixed != -> !==. pnpm test reported all green on local.

I think it is ready to merge. Thank you

rarkins
rarkins previously approved these changes May 30, 2025
@weihanglo
Copy link
Author

Thanks for the review!

I am not sure what went wrong in the test coverage though: https://app.codecov.io/gh/renovatebot/renovate/pull/36005

@zharinov
Copy link
Collaborator

Thanks for the review!

I am not sure what went wrong in the test coverage though: https://app.codecov.io/gh/renovatebot/renovate/pull/36005

Yeah, it's branches in ?? conditional, very annoying, but usually could be fixed by providing data for the rightmost value in expression

@weihanglo
Copy link
Author

Thanks. 661d18d fixes the missing branch coverage I believe.

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

otherwise LGTM

@@ -112,6 +112,9 @@ export class CrateDatasource extends Datasource {
const release: Release = {
version: version.vers.replace(/\+.*$/, ''),
};
if (release.version !== version.vers) {
release.versionOrig = version.vers;
Copy link
Member

Choose a reason for hiding this comment

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

@rarkins I think it should be stored in a property like the managerData instead because this field can be overwritten by a user extract config 🤔

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.

5 participants