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

Method run

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

Source from the content-addressed store, hash-verified

166
167impl Command for Create {
168 fn run(&self) -> CliResult<()> {
169 // Get the tag name
170 let name = self
171 .name
172 .as_ref()
173 .ok_or_else(|| CliError::InvalidArgument {
174 message: "Tag name is required".to_string(),
175 })?;
176
177 // Find the repository
178 let repo_root = find_repository_root()?;
179 let repo = Repository::open(&repo_root).map_err(|e| match e {
180 atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound {
181 searched_path: path.into(),
182 },
183 other => CliError::Repository(other),
184 })?;
185
186 // Check for existing tag — fail unless --force
187 if let Ok(Some(_)) = repo.get_tag(name) {
188 if self.force {
189 let _ = repo.delete_tag(name);
190 } else {
191 return Err(CliError::InvalidArgument {
192 message: format!("Tag '{}' already exists. Use --force to overwrite.", name),
193 });
194 }
195 }
196
197 // Create the tag
198 let tag = repo
199 .create_tag(name, self.message.as_deref(), TagKind::Release)
200 .map_err(|e| match e {
201 atomic_repository::RepositoryError::TagAlreadyExists { name } => {
202 CliError::InvalidArgument {
203 message: format!(
204 "Tag '{}' already exists. Use --force to overwrite.",
205 name
206 ),
207 }
208 }
209 atomic_repository::RepositoryError::InvalidTagName { name, reason } => {
210 CliError::InvalidArgument {
211 message: format!("Invalid tag name '{}': {}", name, reason),
212 }
213 }
214 atomic_repository::RepositoryError::ViewNotFound { name } => {
215 CliError::ViewNotFound { name }
216 }
217 other => CliError::Repository(other),
218 })?;
219
220 // Print success message
221 if tag.is_annotated() {
222 print_success(&format!("Created annotated tag: {}", emphasis(&tag.name)));
223 } else {
224 print_success(&format!("Created tag: {}", emphasis(&tag.name)));
225 }

Calls 8

find_repository_rootFunction · 0.85
RepositoryClass · 0.85
print_successFunction · 0.85
as_refMethod · 0.80
delete_tagMethod · 0.80
create_tagMethod · 0.80
is_annotatedMethod · 0.80
get_tagMethod · 0.45