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

Method run

atomic-cli/src/commands/tag/delete.rs:63–104  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

61
62impl Command for Delete {
63 fn run(&self) -> CliResult<()> {
64 // Route every form through the service layer (the handler runs the
65 // same domain delete and the wire carries the existed flag).
66 if crate::commands::rpc::tag_delete(self)? {
67 return Ok(());
68 }
69
70 // Get the tag name
71 let name = self
72 .name
73 .as_ref()
74 .ok_or_else(|| CliError::InvalidArgument {
75 message: "Tag name is required".to_string(),
76 })?;
77
78 // Find the repository
79 let repo_root = find_repository_root()?;
80 let mut repo =
81 Repository::open_for_workspace_transaction(&repo_root).map_err(|e| match e {
82 atomic_repository::RepositoryError::NotFound { path } => {
83 CliError::RepositoryNotFound {
84 searched_path: path.into(),
85 }
86 }
87 other => CliError::Repository(other),
88 })?;
89
90 let workspace = enter_workspace(&mut repo, WorkspaceTxnMode::Reconcile)?;
91
92 // Delete the tag
93 let deleted = repo
94 .delete_tag_from_view(name, &workspace.view().name)
95 .map_err(CliError::Repository)?;
96
97 if deleted {
98 print_success(&format!("Deleted tag: {}", emphasis(name)));
99 } else {
100 println!("{}", hint(&format!("Tag '{}' does not exist", name)));
101 }
102
103 Ok(())
104 }
105}
106
107// Tests

Callers 4

test_run_without_nameFunction · 0.45
test_delete_existing_tagFunction · 0.45

Calls 8

tag_deleteFunction · 0.85
find_repository_rootFunction · 0.85
RepositoryClass · 0.85
print_successFunction · 0.85
as_refMethod · 0.80
delete_tag_from_viewMethod · 0.80
enter_workspaceFunction · 0.50
viewMethod · 0.45

Tested by 4

test_run_without_nameFunction · 0.36
test_delete_existing_tagFunction · 0.36