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

Method run

atomic-cli/src/commands/unrecord.rs:85–129  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

83
84impl Command for Unrecord {
85 fn run(&self) -> CliResult<()> {
86 let repo_root = find_repository_root()?;
87 let repo = Repository::open(&repo_root).map_err(|e| match e {
88 atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound {
89 searched_path: path.into(),
90 },
91 other => CliError::Repository(other),
92 })?;
93
94 let options = if self.dry_run {
95 UnrecordOptions::dry_run()
96 } else {
97 UnrecordOptions::new()
98 };
99
100 let outcome = if let Some(ref prefix) = self.change {
101 let hash = resolve_change(&repo, prefix)?;
102 repo.unrecord(&hash, options)
103 .map_err(CliError::Repository)?
104 } else {
105 // Unrecord the most recent change
106 repo.unrecord_last(options).map_err(|e| match e {
107 atomic_repository::RepositoryError::Unrecord(msg)
108 if msg.contains("empty") || msg.contains("Empty") =>
109 {
110 CliError::InvalidArgument {
111 message: "View is empty — nothing to unrecord".to_string(),
112 }
113 }
114 other => CliError::Repository(other),
115 })?
116 };
117
118 if outcome.was_dry_run {
119 for hash in &outcome.unrecorded {
120 print_warning(&format!("Would unrecord: {}", hash.to_base32()));
121 }
122 } else {
123 for hash in &outcome.unrecorded {
124 print_success(&format!("Unrecorded: {}", hash.to_base32()));
125 }
126 }
127
128 Ok(())
129 }
130}
131
132fn resolve_change(repo: &Repository, prefix: &str) -> CliResult<Hash> {

Callers

nothing calls this directly

Calls 8

find_repository_rootFunction · 0.85
RepositoryClass · 0.85
resolve_changeFunction · 0.85
print_warningFunction · 0.85
print_successFunction · 0.85
unrecordMethod · 0.80
unrecord_lastMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected