Add --group and --only-group to uv sync and includes all groups in uv lock (#8110)
Part of #8090 Adds the ability to include a group (`--group`) in the sync or _only_ sync a group (`--only-group`). Includes all groups in the resolution, which will have the same limitations as extras as described in #6981. There's a great deal of refactoring of the "development" concept into "groups" behind the scenes that I am continuing to defer here to minimize the diff. Additionally, this does not yet resolve interactions with the existing `dev` group — we'll tackle that separately as well. I probably won't merge the stack until that design is resolved. The current proposal is that we'll just "combine' the `dev-dependencies` contents into the `dev` group.
This commit is contained in:
@@ -61,3 +61,39 @@ impl From<DevMode> for DevSpecification {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DevSpecification {
|
||||
/// Determine the [`DevSpecification`] policy from the command-line arguments.
|
||||
pub fn from_args(
|
||||
dev: bool,
|
||||
no_dev: bool,
|
||||
only_dev: bool,
|
||||
group: Vec<GroupName>,
|
||||
only_group: Vec<GroupName>,
|
||||
) -> Self {
|
||||
let from_mode = DevSpecification::from(DevMode::from_args(dev, no_dev, only_dev));
|
||||
if !group.is_empty() {
|
||||
match from_mode {
|
||||
DevSpecification::Exclude => Self::Include(group),
|
||||
DevSpecification::Include(dev) => {
|
||||
Self::Include(group.into_iter().chain(dev).collect())
|
||||
}
|
||||
DevSpecification::Only(_) => {
|
||||
unreachable!("cannot specify both `--only-dev` and `--group`")
|
||||
}
|
||||
}
|
||||
} else if !only_group.is_empty() {
|
||||
match from_mode {
|
||||
DevSpecification::Exclude => Self::Only(only_group),
|
||||
DevSpecification::Only(dev) => {
|
||||
Self::Only(only_group.into_iter().chain(dev).collect())
|
||||
}
|
||||
// TODO(zanieb): `dev` defaults to true we can't tell if `--dev` was provided in
|
||||
// conflict with `--only-group` here
|
||||
DevSpecification::Include(_) => Self::Only(only_group),
|
||||
}
|
||||
} else {
|
||||
from_mode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user