Skip to content

Commit ec5b8d5

Browse files
committed
fix: invalidate lockfile when git rev (non-commit-hash) is removed from manifest
When a user specifies `rev = "main"` in pixi.toml and later removes it, the lockfile should be invalidated and re-resolved. Previously, any `Rev(_)` in the lockfile was treated as satisfiable when the manifest had no explicit rev (DefaultBranch). This was incorrect because `Rev("main")` is a named reference, not a specific commit hash. Now the satisfiability check distinguishes between: - `Rev(full_commit_hash)` → satisfiable (specific commit is still valid) - `Rev(non_hash)` like "main" → NOT satisfiable, triggers re-resolve Fixes the issue reported by Ruben in PR #5215.
1 parent 1e3f173 commit ec5b8d5

File tree

1 file changed

+25
-4
lines changed
  • crates/pixi_core/src/lock_file/satisfiability

1 file changed

+25
-4
lines changed

crates/pixi_core/src/lock_file/satisfiability/mod.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,11 @@ pub(crate) fn pypi_satifisfies_requirement(
973973
// If the spec uses DefaultBranch, we need to check what the lock has:
974974
// - If lock has Branch("main") or Tag("v1.0") → NOT satisfiable
975975
// (user removed explicit branch/tag, should re-resolve)
976-
// - If lock has DefaultBranch or Rev (specific commit) → satisfiable
976+
// - If lock has DefaultBranch → satisfiable
977+
// - If lock has Rev with full commit hash → satisfiable
977978
// (specific commit is still valid even without explicit ref)
979+
// - If lock has Rev with non-hash (like "main") → NOT satisfiable
980+
// (user removed explicit rev, should re-resolve)
978981
if *reference == GitReference::DefaultBranch {
979982
match &pinned_git_spec.source.reference {
980983
// These are explicit named references - not satisfiable
@@ -988,11 +991,29 @@ pub(crate) fn pypi_satifisfies_requirement(
988991
}
989992
.into());
990993
}
991-
// These are satisfiable - either DefaultBranch or specific commits
992-
pixi_spec::GitReference::DefaultBranch
993-
| pixi_spec::GitReference::Rev(_) => {
994+
// DefaultBranch in lock is satisfiable
995+
pixi_spec::GitReference::DefaultBranch => {
994996
return Ok(());
995997
}
998+
// Rev is only satisfiable if it's a full commit hash.
999+
// If the rev is NOT a full commit hash (like "main"), it's a named
1000+
// reference that was explicitly set and should trigger re-resolve
1001+
// when the user removes it from the manifest.
1002+
pixi_spec::GitReference::Rev(_) => {
1003+
if pinned_git_spec.source.reference.as_full_commit().is_some() {
1004+
return Ok(());
1005+
} else {
1006+
return Err(PlatformUnsat::LockedPyPIGitRefMismatch {
1007+
name: spec.name.clone().to_string(),
1008+
expected_ref: reference.to_string(),
1009+
found_ref: pinned_git_spec
1010+
.source
1011+
.reference
1012+
.to_string(),
1013+
}
1014+
.into());
1015+
}
1016+
}
9961017
}
9971018
}
9981019

0 commit comments

Comments
 (0)