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

Function load_change_data

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

Load and serialize change data from the repository. Loads the change from the repository and serializes it to bytes suitable for uploading to a remote. # Arguments `repo` - The repository to load from `hash` - The hash of the change to load # Returns The serialized change data as bytes. # Errors Returns `CliError::ChangeNotFound` if the change doesn't exist, or `CliError::Internal` if seria

(repo: &Repository, hash: &Hash)

Source from the content-addressed store, hash-verified

174/// Returns `CliError::ChangeNotFound` if the change doesn't exist,
175/// or `CliError::Internal` if serialization fails.
176pub fn load_change_data(repo: &Repository, hash: &Hash) -> CliResult<Bytes> {
177 // Load the change
178 let change = repo
179 .load_change(hash)
180 .map_err(|_| CliError::ChangeNotFound {
181 hash: hash.to_base32(),
182 })?;
183
184 // Serialize to bytes
185 let mut buffer = Vec::new();
186 change
187 .serialize(&mut buffer)
188 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to serialize change: {}", e)))?;
189
190 Ok(Bytes::from(buffer))
191}
192
193/// Get the on-disk path of a change file for direct file-based push.
194///

Callers 1

upload_change_smartFunction · 0.70

Calls 3

load_changeMethod · 0.45
to_base32Method · 0.45
serializeMethod · 0.45

Tested by

no test coverage detected