mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-06 18:50:36 +00:00
Implement --show-version-specifiers
for tree
(#5240)
## Summary resolves https://github.com/astral-sh/uv/issues/5217 ## Test Plan existing tests pass (should be perfectly backwards compatible) + added a few tests to cover the new functionality. in particular, in addition to the simple use of `--show-version-specifiers`, its interaction with `--invert` and `--package` flags are tested.
This commit is contained in:
parent
1b09cb26f5
commit
12518a01a4
8 changed files with 389 additions and 17 deletions
|
@ -392,6 +392,24 @@ impl RequirementSource {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convert the source to a version specifier or URL.
|
||||
///
|
||||
/// If the source is a registry and the specifier is empty, it returns `None`.
|
||||
pub fn version_or_url(&self) -> Option<VersionOrUrl<VerbatimParsedUrl>> {
|
||||
match self {
|
||||
Self::Registry { specifier, .. } => {
|
||||
if specifier.len() == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(VersionOrUrl::VersionSpecifier(specifier.clone()))
|
||||
}
|
||||
}
|
||||
Self::Url { .. } | Self::Git { .. } | Self::Path { .. } | Self::Directory { .. } => {
|
||||
Some(VersionOrUrl::Url(self.to_verbatim_parsed_url()?))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the source is editable.
|
||||
pub fn is_editable(&self) -> bool {
|
||||
matches!(self, Self::Directory { editable: true, .. })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue