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

Function read_version

atomic-core/src/pristine/build_metadata.rs:34–48  ·  view source on GitHub ↗

Read a recorded build identity without creating metadata in legacy databases.

(txn: &redb::ReadTransaction, key: &str)

Source from the content-addressed store, hash-verified

32
33/// Read a recorded build identity without creating metadata in legacy databases.
34pub fn read_version(txn: &redb::ReadTransaction, key: &str) -> PristineResult<Option<String>> {
35 let table = match txn.open_table(ATOMIC_META) {
36 Ok(table) => table,
37 Err(TableError::TableDoesNotExist(_)) => return Ok(None),
38 Err(error) => return Err(error.into()),
39 };
40 let Some(value) = table.get(key)? else {
41 return Ok(None);
42 };
43 let value =
44 std::str::from_utf8(value.value()).map_err(|_| super::PristineError::Inconsistent {
45 message: format!("repository build metadata {key} is not UTF-8"),
46 })?;
47 Ok(Some(value.to_owned()))
48}
49
50#[cfg(test)]
51mod tests {

Callers 1

build_versionFunction · 0.85

Calls 2

valueMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected