uv/crates/uv-configuration/src/sources.rs
Charlie Marsh f89403f4f6
Retain and respect settings in tool upgrades (#5937)
## Summary

We now persist the `ResolverInstallerOptions` when writing out a tool
receipt. When upgrading, we grab the saved options, and merge with the
command-line arguments and user-level filesystem settings (CLI > receipt
> filesystem).
2024-08-09 18:21:49 +00:00

20 lines
603 B
Rust

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
pub enum SourceStrategy {
/// Use `tool.uv.sources` when resolving dependencies.
#[default]
Enabled,
/// Ignore `tool.uv.sources` when resolving dependencies.
Disabled,
}
impl SourceStrategy {
/// Return the [`SourceStrategy`] from the command-line arguments, if any.
pub fn from_args(no_sources: bool) -> Self {
if no_sources {
Self::Disabled
} else {
Self::Enabled
}
}
}