MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / clean_up_local_config

Function clean_up_local_config

atomic-cli/src/commands/workspace/delete.rs:124–153  ·  view source on GitHub ↗

Remove a deleted workspace from the active server profile's `default_workspaces` if it was the configured default for its org. Operates on the **active** server profile (the same one `atomic workspace set` writes to) so cleanup stays consistent when a named profile is active.

(org_slug: &str, deleted_workspace: &str)

Source from the content-addressed store, hash-verified

122/// `atomic workspace set` writes to) so cleanup stays consistent when a
123/// named profile is active.
124fn clean_up_local_config(org_slug: &str, deleted_workspace: &str) -> CliResult<()> {
125 let mut config = GlobalConfig::load()
126 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load global config: {e}")))?;
127
128 let (server, _name) = config
129 .resolve_server_mut(None)
130 .map_err(|e| CliError::Internal(anyhow::anyhow!("{e}")))?;
131
132 let was_default = server
133 .default_workspaces
134 .get(org_slug)
135 .map(|v| v == deleted_workspace)
136 .unwrap_or(false);
137
138 if !was_default {
139 return Ok(());
140 }
141
142 server.default_workspaces.remove(org_slug);
143 config
144 .save()
145 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to save global config: {e}")))?;
146
147 print_hint(&format!(
148 "Default workspace for '{org_slug}' was '{deleted_workspace}' — \
149 run 'atomic workspace set <slug>' to pick a new one."
150 ));
151
152 Ok(())
153}
154
155#[cfg(test)]
156mod tests {

Callers 1

runMethod · 0.70

Calls 5

print_hintFunction · 0.85
resolve_server_mutMethod · 0.80
getMethod · 0.65
removeMethod · 0.65
saveMethod · 0.45

Tested by

no test coverage detected