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:120–146  ·  view source on GitHub ↗

Remove a deleted workspace from `[server.default_workspaces]` if it was the configured default for its org.

(org_slug: &str, deleted_workspace: &str)

Source from the content-addressed store, hash-verified

118/// Remove a deleted workspace from `[server.default_workspaces]` if it was
119/// the configured default for its org.
120fn clean_up_local_config(org_slug: &str, deleted_workspace: &str) -> CliResult<()> {
121 let mut config = GlobalConfig::load()
122 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load global config: {e}")))?;
123
124 let was_default = config
125 .server
126 .default_workspaces
127 .get(org_slug)
128 .map(|v| v == deleted_workspace)
129 .unwrap_or(false);
130
131 if !was_default {
132 return Ok(());
133 }
134
135 config.server.default_workspaces.remove(org_slug);
136 config
137 .save()
138 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to save global config: {e}")))?;
139
140 print_hint(&format!(
141 "Default workspace for '{org_slug}' was '{deleted_workspace}' — \
142 run 'atomic workspace set <slug>' to pick a new one."
143 ));
144
145 Ok(())
146}
147
148#[cfg(test)]
149mod tests {

Callers 1

runMethod · 0.70

Calls 4

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

Tested by

no test coverage detected