Skip to content

feat: add support for Cargo.lock version update #1402

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 4 commits into
base: master
Choose a base branch
from

Conversation

tunakasif
Copy link

Description

As depicted in #1201:

In Rust, when you change the version of the app, the Cargo.lock file must be changed too.

This PR introduces the capability of updating the package version in the Cargo.lock file, where the package name is the one defined in Cargo.toml, for the cargo version provider.

Checklist

  • Add test cases to all the changes you introduce
  • Run poetry all locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

For cargo version provider, if a Cargo.lock file also exists within the same directory as Cargo.toml, the Cargo.lock's package.version field whose package.name field is the same as Cargo.toml's package.name field should be updated along with Cargo.toml.

Additional context

Resolves: #1201

tunakasif added 4 commits May 8, 2025 22:55
If `Cargo.lock` file is present in the same path as the `Cargo.toml`,
the version of the package will also be updated in the `Cargo.lock`
file.

The implementation is similar to the one used for `UvProvider`, which
extends the `CargoProvider` to handle lock files. The change does not
break any existing functionality, if the `Cargo.lock` file is not
present, since it checks for the existence of the file before
attempting a lock file update.
To add more test variables, increase the verbosity of current ones
and make them more clear.
Add a test to check the behavior of the cargo provider when a
`Cargo.lock` file is present. This test ensures that the
`CargoProvider` behaves correctly when the lock file is present, and
updates both the `Cargo.lock` and `Cargo.toml` files accordingly.
Add `Cargo.lock` update information to the documentation.
Copy link

codecov bot commented May 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.57%. Comparing base (120d514) to head (4501f85).
Report is 599 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1402      +/-   ##
==========================================
+ Coverage   97.33%   97.57%   +0.23%     
==========================================
  Files          42       57      +15     
  Lines        2104     2680     +576     
==========================================
+ Hits         2048     2615     +567     
- Misses         56       65       +9     
Flag Coverage Δ
unittests 97.57% <100.00%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

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

Thanks!

@Lee-W Lee-W added pr-status: ready-to-merge almost ready to merge. just keep it for a few days for others to check and removed pr-status: wait-for-review labels May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: ready-to-merge almost ready to merge. just keep it for a few days for others to check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cargo.lock must be updated too for version
2 participants