mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-17 13:58:29 +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
|
@ -567,6 +567,15 @@ pub enum VersionOrUrl<T: Pep508Url = VerbatimUrl> {
|
|||
Url(T),
|
||||
}
|
||||
|
||||
impl<T: Pep508Url> Display for VersionOrUrl<T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::VersionSpecifier(version_specifier) => Display::fmt(version_specifier, f),
|
||||
Self::Url(url) => Display::fmt(url, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Unowned version specifier or URL to install.
|
||||
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)]
|
||||
pub enum VersionOrUrlRef<'a, T: Pep508Url = VerbatimUrl> {
|
||||
|
@ -576,6 +585,15 @@ pub enum VersionOrUrlRef<'a, T: Pep508Url = VerbatimUrl> {
|
|||
Url(&'a T),
|
||||
}
|
||||
|
||||
impl<T: Pep508Url> Display for VersionOrUrlRef<'_, T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::VersionSpecifier(version_specifier) => Display::fmt(version_specifier, f),
|
||||
Self::Url(url) => Display::fmt(url, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a VersionOrUrl> for VersionOrUrlRef<'a> {
|
||||
fn from(value: &'a VersionOrUrl) -> Self {
|
||||
match value {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue