From 07b9bd34e718135ab46e67625f0eae96f56ff72b Mon Sep 17 00:00:00 2001 From: Greg Schoeninger Date: Fri, 20 Dec 2024 21:36:44 -0800 Subject: [PATCH] re-use workspace by name --- oxen/Cargo.lock | 4 ++-- oxen/Cargo.toml | 2 +- oxen/src/py_workspace.rs | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/oxen/Cargo.lock b/oxen/Cargo.lock index 2c6cc31..85340f5 100644 --- a/oxen/Cargo.lock +++ b/oxen/Cargo.lock @@ -3065,9 +3065,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "liboxen" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278dec93798898bcb0ca4f135642099ae5d35850b594aa50e6e19d9482efd97d" +checksum = "ff3a79a9597b91659b8f54b40449abb45394d997bfaf9b8bb8c8966e81295ad8" dependencies = [ "actix-files", "actix-web", diff --git a/oxen/Cargo.toml b/oxen/Cargo.toml index a2d6d6c..553d851 100644 --- a/oxen/Cargo.toml +++ b/oxen/Cargo.toml @@ -28,7 +28,7 @@ polars = { version = "0.44.0", features = [ ] } serde_json = "1.0.106" uuid = { version = "1.4.1", features = ["serde", "v4"] } -liboxen = "0.24.0" +liboxen = "0.24.1" # liboxen = { path = "../../Oxen/src/lib" } [build-dependencies] diff --git a/oxen/src/py_workspace.rs b/oxen/src/py_workspace.rs index 878b579..9a4dcaf 100644 --- a/oxen/src/py_workspace.rs +++ b/oxen/src/py_workspace.rs @@ -30,6 +30,19 @@ impl PyWorkspace { ) -> Result { let name = name.unwrap_or_else(|| format!("workspace-{}", Uuid::new_v4())); + // Get the workspace by name + let workspace = pyo3_asyncio::tokio::get_runtime().block_on(async { + api::client::workspaces::get_by_name(&repo.repo, &name).await + })?; + + if let Some(workspace) = workspace { + return Ok(Self { + repo, + branch_name: branch_name.clone(), + id: workspace.id, + }); + } + let workspace = pyo3_asyncio::tokio::get_runtime().block_on(async { api::client::workspaces::create_with_path( &repo.repo,