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

Method run

atomic-cli/src/commands/tag/create.rs:169–252  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

167
168impl Command for Create {
169 fn run(&self) -> CliResult<()> {
170 // Route every form through the service layer (the handler runs the
171 // same domain flow: the existing-tag pre-check, the --force delete,
172 // the Release kind create).
173 if crate::commands::rpc::tag_create(self)? {
174 return Ok(());
175 }
176
177 // Get the tag name
178 let name = self
179 .name
180 .as_ref()
181 .ok_or_else(|| CliError::InvalidArgument {
182 message: "Tag name is required".to_string(),
183 })?;
184
185 // Find the repository
186 let repo_root = find_repository_root()?;
187 let mut repo =
188 Repository::open_for_workspace_transaction(&repo_root).map_err(|e| match e {
189 atomic_repository::RepositoryError::NotFound { path } => {
190 CliError::RepositoryNotFound {
191 searched_path: path.into(),
192 }
193 }
194 other => CliError::Repository(other),
195 })?;
196
197 let workspace = enter_workspace(&mut repo, WorkspaceTxnMode::Reconcile)?;
198 let workspace_view = &workspace.view().name;
199 let target_view = self.view.as_deref().unwrap_or(workspace_view);
200
201 // Check for an existing tag. Forced replacement is performed by one
202 // leased repository transition rather than a delete/create pair.
203 if !self.force
204 && repo
205 .get_tag_from_view(name, target_view)
206 .map_err(CliError::Repository)?
207 .is_some()
208 {
209 return Err(CliError::InvalidArgument {
210 message: format!("Tag '{}' already exists. Use --force to overwrite.", name),
211 });
212 }
213
214 // Create the tag
215 let tag = repo
216 .create_tag_on_view(target_view, name, self.message.as_deref(), TagKind::Release)
217 .map_err(|e| match e {
218 atomic_repository::RepositoryError::TagAlreadyExists { name } => {
219 CliError::InvalidArgument {
220 message: format!(
221 "Tag '{}' already exists. Use --force to overwrite.",
222 name
223 ),
224 }
225 }
226 atomic_repository::RepositoryError::InvalidTagName { name, reason } => {

Calls 11

tag_createFunction · 0.85
find_repository_rootFunction · 0.85
RepositoryClass · 0.85
print_successFunction · 0.85
as_refMethod · 0.80
get_tag_from_viewMethod · 0.80
create_tag_on_viewMethod · 0.80
enter_workspaceFunction · 0.50
viewMethod · 0.45
is_annotatedMethod · 0.45