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

Method run

atomic-cli/src/commands/tag/show.rs:70–142  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

68
69impl Command for Show {
70 fn run(&self) -> CliResult<()> {
71 // Get the tag name
72 let name = self
73 .name
74 .as_ref()
75 .ok_or_else(|| CliError::InvalidArgument {
76 message: "Tag name is required".to_string(),
77 })?;
78
79 // Find the repository
80 let repo_root = find_repository_root()?;
81 let repo = Repository::open(&repo_root).map_err(|e| match e {
82 atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound {
83 searched_path: path.into(),
84 },
85 other => CliError::Repository(other),
86 })?;
87
88 // Get the tag
89 let tag = repo.get_tag(name).map_err(CliError::Repository)?;
90
91 match tag {
92 Some(tag) => {
93 println!("{}: {}", emphasis("Tag"), tag.name);
94 println!("{}: {}", emphasis("View"), tag.view);
95 println!("{}: {}", emphasis("Sequence"), tag.sequence);
96 println!("{}: {}", emphasis("State"), tag.state.to_base32());
97 println!(
98 "{}: {}",
99 emphasis("Created"),
100 tag.timestamp.format("%Y-%m-%d %H:%M:%S UTC")
101 );
102 println!("{}: {}", emphasis("Kind"), tag.kind);
103 println!(
104 "{}: {}",
105 emphasis("Type"),
106 if tag.is_annotated() {
107 "annotated"
108 } else {
109 "lightweight"
110 }
111 );
112
113 if let Some(ref message) = tag.message {
114 println!("{}: {}", emphasis("Message"), message);
115 }
116
117 if let Some(ref author) = tag.author {
118 let author_str = match &author.email {
119 Some(email) => format!("{} <{}>", author.name, email),
120 None => author.name.clone(),
121 };
122 println!("{}: {}", emphasis("Author"), author_str);
123 }
124
125 if let Some(ref metadata) = tag.metadata {
126 println!("{}: {}", emphasis("Metadata"), metadata);
127 }

Callers 4

test_run_without_nameFunction · 0.45
test_show_existing_tagFunction · 0.45
test_show_annotated_tagFunction · 0.45

Calls 5

find_repository_rootFunction · 0.85
RepositoryClass · 0.85
as_refMethod · 0.80
get_tagMethod · 0.45
cloneMethod · 0.45

Tested by 4

test_run_without_nameFunction · 0.36
test_show_existing_tagFunction · 0.36
test_show_annotated_tagFunction · 0.36