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

Function reference_transaction_entries

atomic-cli/src/commands/git/hooks.rs:1163–1194  ·  view source on GitHub ↗

Parse reference-transaction stdin lines into recorded movements. Git passes ref *names*, not object IDs, for symbolic-ref updates (e.g. `refs/heads/main HEAD` when HEAD's symref target changes on a plain `git checkout`). Those lines are not OID movements: the advisory evidence journal records value-ID movements only, so a symbolic update is skipped instead of failing the advisory hook with a misl

(input: &str)

Source from the content-addressed store, hash-verified

1161/// validation error. Zero OIDs stay legal for create/delete; every other
1162/// recorded value must be a real object-ID shape.
1163fn reference_transaction_entries(input: &str) -> CliResult<Vec<RefTransactionEntry>> {
1164 let value_is_object_id = |value: &str| {
1165 value.bytes().all(|byte| byte == b'0')
1166 || (matches!(value.len(), 40 | 64)
1167 && value.bytes().all(|byte| byte.is_ascii_hexdigit()))
1168 };
1169 let mut transactions = Vec::new();
1170 for line in input.lines() {
1171 let line = line.trim();
1172 if line.is_empty() {
1173 continue;
1174 }
1175 let mut parts = line.split_whitespace();
1176 let (old_oid, new_oid, ref_name) = match (parts.next(), parts.next(), parts.next()) {
1177 (Some(old_oid), Some(new_oid), Some(ref_name)) => (old_oid, new_oid, ref_name),
1178 _ => {
1179 return Err(git_error(format!(
1180 "reference-transaction line '{line}' is not '<old> <new> <ref>'"
1181 )))
1182 }
1183 };
1184 if !value_is_object_id(old_oid) || !value_is_object_id(new_oid) {
1185 continue;
1186 }
1187 transactions.push(RefTransactionEntry {
1188 ref_name: ref_name.to_string(),
1189 old_oid: old_oid.to_ascii_lowercase(),
1190 new_oid: new_oid.to_ascii_lowercase(),
1191 });
1192 }
1193 Ok(transactions)
1194}
1195
1196/// The identity limit for post-rewrite evidence, quoted verbatim in every
1197/// journal record so downstream readers cannot upgrade it silently.

Calls 7

git_errorFunction · 0.70
allMethod · 0.45
bytesMethod · 0.45
linesMethod · 0.45
is_emptyMethod · 0.45
nextMethod · 0.45
pushMethod · 0.45