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

Function change_file_path

atomic-cli/tests/fixtures/helpers_c5.rs:212–228  ·  view source on GitHub ↗

Get the on-disk path of a change file for direct file-based push. This returns the path to the `.change` file in the repository's change store, enabling `HttpRemote::upload_change_file()` to stream bytes directly from disk without the load → deserialize → re-serialize roundtrip. # Arguments `repo` - The repository containing the change. `hash` - The hash of the change. # Returns The path to t

(repo: &Repository, hash: &Hash)

Source from the content-addressed store, hash-verified

210///
211/// Returns `CliError::ChangeNotFound` if the file doesn't exist.
212pub fn change_file_path(repo: &Repository, hash: &Hash) -> CliResult<std::path::PathBuf> {
213 let base32 = hash.to_base32();
214 let prefix = &base32[..2.min(base32.len())];
215 let filename = format!("{}.change", base32);
216 let path = repo
217 .root()
218 .join(".atomic")
219 .join("changes")
220 .join(prefix)
221 .join(filename);
222
223 if path.exists() {
224 Ok(path)
225 } else {
226 Err(CliError::ChangeNotFound { hash: base32 })
227 }
228}
229
230// =============================================================================
231// Delta Transfer Protocol

Callers

nothing calls this directly

Calls 4

to_base32Method · 0.45
lenMethod · 0.45
rootMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected