Avoid showing duplicate paths in `uv python list` (#6740)

<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary
- Resolves issue #6690
<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan
```
$ cargo run python list
```
<!-- How was it tested? -->

---------

Co-authored-by: leaf-soba <leaf-soba@gmail.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
leaf-soba 2024-08-28 23:48:17 +08:00 committed by GitHub
parent 451eef31a6
commit 71f5998752
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -104,8 +104,16 @@ pub(crate) async fn list(
let mut seen_minor = HashSet::new(); let mut seen_minor = HashSet::new();
let mut seen_patch = HashSet::new(); let mut seen_patch = HashSet::new();
let mut seen_paths = HashSet::new();
let mut include = Vec::new(); let mut include = Vec::new();
for (version, os, key, kind, path) in output.iter().rev() { for (version, os, key, kind, path) in output.iter().rev() {
// Do not show the same path more than once
if let Some(path) = path {
if !seen_paths.insert(path) {
continue;
}
}
// Only show the latest patch version for each download unless all were requested // Only show the latest patch version for each download unless all were requested
if !matches!(kind, Kind::System) { if !matches!(kind, Kind::System) {
if let [major, minor, ..] = version.release() { if let [major, minor, ..] = version.release() {