Skip to content

Commit 38be074

Browse files
committed
fix: rooz new - exit early if workspace already exists and no apply/replace specified
Closes #72 chore: deps
1 parent bd5cfd9 commit 38be074

File tree

3 files changed

+40
-27
lines changed

3 files changed

+40
-27
lines changed

Cargo.lock

+26-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rooz"
3-
version = "0.97.0"
3+
version = "0.98.0"
44
edition = "2021"
55

66
[dependencies]

src/cmd/new.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,19 @@ impl<'a> WorkspaceApi<'a> {
102102
None => (id::random_suffix("tmp"), false, false),
103103
};
104104

105+
let mut labels = Labels {
106+
workspace: Labels::workspace(&workspace_key),
107+
role: Labels::role(labels::ROLE_WORK),
108+
..Default::default()
109+
};
110+
111+
if !apply && !force {
112+
match self.api.container.get_single(&labels).await? {
113+
Some(_) => Err(format!("Container already exists. Did you mean: rooz enter {}? Otherwise, use --apply to reconfigure containers or --replace to recreate the whole workspace.", workspace_key.clone())),
114+
None => Ok(()),
115+
}?;
116+
}
117+
105118
if apply {
106119
self.remove_containers_only(&workspace_key, true).await?;
107120
}
@@ -124,12 +137,6 @@ impl<'a> WorkspaceApi<'a> {
124137
working_dir: work_dir.to_string(),
125138
};
126139

127-
let mut labels = Labels {
128-
workspace: Labels::workspace(&workspace_key),
129-
role: Labels::role(labels::ROLE_WORK),
130-
..Default::default()
131-
};
132-
133140
let cli_cfg = if let Some(source) = &cli_config_path {
134141
match source {
135142
ConfigSource::Body {

0 commit comments

Comments
 (0)