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

Function ephemeral_original_commit

atomic-cli/src/commands/git/shadow.rs:1444–1455  ·  view source on GitHub ↗

Detect an ephemeral `git/ ` view and resolve the commit it adopted. Returns `Some( )` when the view name carries a valid Git OID prefix and that commit still exists in the object database.

(git_repo: &GitRepository, view: &str)

Source from the content-addressed store, hash-verified

1442/// Returns `Some(<full oid>)` when the view name carries a valid Git OID
1443/// prefix and that commit still exists in the object database.
1444pub(crate) fn ephemeral_original_commit(git_repo: &GitRepository, view: &str) -> Option<String> {
1445 let oid = view.strip_prefix("git/")?;
1446 if oid.len() != EPHEMERAL_PREFIX_LEN || !oid.bytes().all(|byte| byte.is_ascii_hexdigit()) {
1447 return None;
1448 }
1449 git_repo
1450 .revparse_single(oid)
1451 .ok()?
1452 .peel_to_commit()
1453 .ok()
1454 .map(|commit| commit.id().to_string())
1455}
1456
1457/// Build, without writing, the switch-path projection commit (RFC §8.2).
1458///

Callers 2

resolve_head_policyFunction · 0.85
run_publishFunction · 0.85

Calls 5

lenMethod · 0.45
allMethod · 0.45
bytesMethod · 0.45
okMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected