Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions crates/uv-distribution-types/src/index_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,22 @@ impl<'a> IndexLocations {
.filter(|index| !index.explicit)
}

/// Return an iterator over all simple [`Index`] entries in order.
///
/// If `no_index` was enabled, then this always returns an empty iterator.
pub fn simple_indexes(&'a self) -> impl Iterator<Item = &'a Index> + 'a {
if self.no_index {
Either::Left(std::iter::empty())
} else {
let mut seen = FxHashSet::default();
Either::Right(
self.indexes.iter().filter(move |index| {
index.name.as_ref().map_or(true, |name| seen.insert(name))
}),
)
}
}

/// Return an iterator over the [`FlatIndexLocation`] entries.
pub fn flat_indexes(&'a self) -> impl Iterator<Item = &'a Index> + 'a {
self.flat_index.iter()
Expand Down
4 changes: 2 additions & 2 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
let (publish_url, check_url) = if let Some(index_name) = index {
debug!("Publishing with index {index_name}");
let index = index_locations
.indexes()
.simple_indexes()
.find(|index| {
index
.name
Expand All @@ -1227,7 +1227,7 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
})
.with_context(|| {
let mut index_names: Vec<String> = index_locations
.indexes()
.simple_indexes()
.filter_map(|index| index.name.as_ref())
.map(ToString::to_string)
.collect();
Expand Down
1 change: 1 addition & 0 deletions crates/uv/tests/it/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ fn invalid_index() {
version = "0.1.0"

[[tool.uv.index]]
explicit = true
name = "foo"
url = "https://example.com"

Expand Down