mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-22 12:35:36 +00:00
Invalidate lockfile when empty dependency groups are added or removed (#12010)
## Summary Since https://github.com/astral-sh/uv/pull/8598, we (correctly) include empty groups in the lockfile, so we can validate them properly in the satisfaction check. Closes https://github.com/astral-sh/uv/issues/12007.
This commit is contained in:
parent
40dce4e009
commit
626fff1be7
2 changed files with 248 additions and 2 deletions
|
|
@ -587,6 +587,13 @@ impl Lock {
|
|||
(self.version(), self.revision()) >= (1, 1)
|
||||
}
|
||||
|
||||
/// Returns `true` if this [`Lock`] includes entries for empty `dependency-group` metadata.
|
||||
pub fn includes_empty_groups(&self) -> bool {
|
||||
// Empty dependency groups are included as of https://github.com/astral-sh/uv/pull/8598,
|
||||
// but Version 1 Revision 1 is the first revision published after that change.
|
||||
(self.version(), self.revision()) >= (1, 1)
|
||||
}
|
||||
|
||||
/// Returns the lockfile version.
|
||||
pub fn version(&self) -> u32 {
|
||||
self.version
|
||||
|
|
@ -1099,7 +1106,7 @@ impl Lock {
|
|||
// Validate the `dependency-groups` metadata.
|
||||
let expected: BTreeMap<GroupName, BTreeSet<Requirement>> = dependency_groups
|
||||
.into_iter()
|
||||
.filter(|(_, requirements)| !requirements.is_empty())
|
||||
.filter(|(_, requirements)| self.includes_empty_groups() || !requirements.is_empty())
|
||||
.map(|(group, requirements)| {
|
||||
Ok::<_, LockError>((
|
||||
group,
|
||||
|
|
@ -1114,7 +1121,7 @@ impl Lock {
|
|||
.metadata
|
||||
.dependency_groups
|
||||
.iter()
|
||||
.filter(|(_, requirements)| !requirements.is_empty())
|
||||
.filter(|(_, requirements)| self.includes_empty_groups() || !requirements.is_empty())
|
||||
.map(|(group, requirements)| {
|
||||
Ok::<_, LockError>((
|
||||
group.clone(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue