mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Use asterisk for dependency cycles in uv pip tree
(#4626)
## Summary Use an asterisk to indicate dependency cycles, along with de-duplicated packages. Purely an aesthetic change.
This commit is contained in:
parent
a444e59668
commit
72438ef5bb
2 changed files with 13 additions and 18 deletions
|
@ -57,14 +57,12 @@ pub(crate) fn pip_tree(
|
|||
.join("\n");
|
||||
writeln!(printer.stdout(), "{rendered_tree}").unwrap();
|
||||
if rendered_tree.contains('*') {
|
||||
writeln!(
|
||||
printer.stdout(),
|
||||
"{}",
|
||||
let message = if no_dedupe {
|
||||
"(*) Package tree is a cycle and cannot be shown".italic()
|
||||
} else {
|
||||
"(*) Package tree already displayed".italic()
|
||||
)?;
|
||||
}
|
||||
if rendered_tree.contains('#') {
|
||||
writeln!(printer.stdout(), "{}", "(#) Dependency cycle".italic())?;
|
||||
};
|
||||
writeln!(printer.stdout(), "{message}")?;
|
||||
}
|
||||
|
||||
// Validate that the environment is consistent.
|
||||
|
@ -176,13 +174,10 @@ impl<'a> DisplayDependencyGraph<'a> {
|
|||
let is_visited = visited.contains(&package_name);
|
||||
let line = format!("{} v{}", package_name, installed_dist.version());
|
||||
|
||||
if path.contains(&package_name) {
|
||||
return vec![format!("{} (#)", line)];
|
||||
}
|
||||
|
||||
// If the package has been visited and de-duplication is enabled (default),
|
||||
// skip the traversal.
|
||||
if is_visited && !self.no_dedupe {
|
||||
// Skip the traversal if
|
||||
// 1. the package is in the current traversal path (i.e. a dependency cycle)
|
||||
// 2. if the package has been visited and de-duplication is enabled (default)
|
||||
if path.contains(&package_name) || (is_visited && !self.no_dedupe) {
|
||||
return vec![format!("{} (*)", line)];
|
||||
}
|
||||
|
||||
|
|
|
@ -623,8 +623,8 @@ fn cyclic_dependency() {
|
|||
uv-cyclic-dependencies-c v0.1.0
|
||||
└── uv-cyclic-dependencies-a v0.1.0
|
||||
└── uv-cyclic-dependencies-b v0.1.0
|
||||
└── uv-cyclic-dependencies-a v0.1.0 (#)
|
||||
(#) Dependency cycle
|
||||
└── uv-cyclic-dependencies-a v0.1.0 (*)
|
||||
(*) Package tree already displayed
|
||||
|
||||
----- stderr -----
|
||||
"###
|
||||
|
@ -906,8 +906,8 @@ fn no_dedupe_and_cycle() {
|
|||
uv-cyclic-dependencies-c v0.1.0
|
||||
└── uv-cyclic-dependencies-a v0.1.0
|
||||
└── uv-cyclic-dependencies-b v0.1.0
|
||||
└── uv-cyclic-dependencies-a v0.1.0 (#)
|
||||
(#) Dependency cycle
|
||||
└── uv-cyclic-dependencies-a v0.1.0 (*)
|
||||
(*) Package tree is a cycle and cannot be shown
|
||||
|
||||
----- stderr -----
|
||||
"###
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue