Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Respect the existing `Cargo.lock` with `--version-range`/`--rust-version` except when necessary to work around old cargo bugs. ([#242](https://github.com/taiki-e/cargo-hack/pull/242))
If you want to ensure that the existing `Cargo.lock` is respected in all cases, please use `--locked`.

## [0.6.23] - 2024-03-27

- Fix ignoring optional dependencies when namespaced dependencies are used. ([#241](https://github.com/taiki-e/cargo-hack/pull/241), thanks @xStrom)
Expand Down
14 changes: 12 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ fn try_main() -> Result<()> {
}
}
}
let versions = versions; // make immutable
if versions.is_empty() {
// TODO: emit warning
return Ok(());
}

for (cargo_version, packages) in &versions {
for package in packages {
Expand All @@ -114,7 +119,12 @@ fn try_main() -> Result<()> {

// First, generate the lockfile using the oldest cargo specified.
// https://github.com/taiki-e/cargo-hack/issues/105
let mut generate_lockfile = !cx.locked;
// For now, only generate lockfile if min version is pre-1.60.
// (If future cargo introduces compatibility issues, the number of
// versions requiring generate-lockfile will probably increase.)
// https://github.com/taiki-e/cargo-hack/issues/234#issuecomment-2028517197
let mut generate_lockfile =
!cx.locked && versions.first_key_value().unwrap().0.minor < 60;
// Workaround for spurious "failed to select a version" error.
// (This does not work around the underlying cargo bug: https://github.com/rust-lang/cargo/issues/10623)
let mut regenerate_lockfile_on_51_or_up = false;
Expand Down Expand Up @@ -381,7 +391,7 @@ fn versioned_cargo_exec_on_packages(
*generate_lockfile = false;
*regenerate_lockfile_on_51_or_up = false;
}
if cargo_version < 51 {
if !cx.locked && cargo_version < 51 {
*regenerate_lockfile_on_51_or_up = true;
}

Expand Down