Respect exclusions in uv init (#5318)

## Summary

Avoid adding to the workspace.

Closes https://github.com/astral-sh/uv/issues/5254.
This commit is contained in:
Charlie Marsh 2024-07-22 20:15:17 -04:00 committed by GitHub
parent 13dd8853d9
commit 2f768b8bb0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 84 additions and 15 deletions

View file

@ -330,6 +330,21 @@ impl Workspace {
&self.pyproject_toml
}
/// Returns `true` if the path is excluded by the workspace.
pub fn excludes(&self, project_path: &Path) -> Result<bool, WorkspaceError> {
if let Some(workspace) = self
.pyproject_toml
.tool
.as_ref()
.and_then(|tool| tool.uv.as_ref())
.and_then(|uv| uv.workspace.as_ref())
{
is_excluded_from_workspace(project_path, &self.install_path, workspace)
} else {
Ok(false)
}
}
/// Collect the workspace member projects from the `members` and `excludes` entries.
async fn collect_members(
workspace_root: PathBuf,