Do not require workspace members to sync with --frozen (#6737)

## Summary

Closes https://github.com/astral-sh/uv/issues/6685.
This commit is contained in:
Charlie Marsh 2024-08-28 07:58:50 -04:00 committed by GitHub
parent 485e0d2748
commit 53ef633c6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 85 additions and 27 deletions

View file

@ -44,12 +44,23 @@ pub enum WorkspaceError {
Normalize(#[source] std::io::Error),
}
#[derive(Debug, Default, Clone)]
pub enum MemberDiscovery<'a> {
/// Discover all workspace members.
#[default]
All,
/// Don't discover any workspace members.
None,
/// Discover workspace members, but ignore the given paths.
Ignore(FxHashSet<&'a Path>),
}
#[derive(Debug, Default, Clone)]
pub struct DiscoveryOptions<'a> {
/// The path to stop discovery at.
pub stop_discovery_at: Option<&'a Path>,
/// The set of member paths to ignore.
pub ignore: FxHashSet<&'a Path>,
/// The strategy to use when discovering workspace members.
pub members: MemberDiscovery<'a>,
}
/// A workspace, consisting of a root directory and members. See [`ProjectWorkspace`].
@ -546,7 +557,12 @@ impl Workspace {
.clone();
// If the directory is explicitly ignored, skip it.
if options.ignore.contains(member_root.as_path()) {
let skip = match &options.members {
MemberDiscovery::All => false,
MemberDiscovery::None => true,
MemberDiscovery::Ignore(ignore) => ignore.contains(member_root.as_path()),
};
if skip {
debug!(
"Ignoring workspace member: `{}`",
member_root.simplified_display()