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

Function ephemeral_original_commit

atomic-cli/src/commands/git/shadow.rs:1632–1643  ·  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

1630/// Returns `Some(<full oid>)` when the view name carries a valid Git OID
1631/// prefix and that commit still exists in the object database.
1632pub(crate) fn ephemeral_original_commit(git_repo: &GitRepository, view: &str) -> Option<String> {
1633 let oid = view.strip_prefix("git/")?;
1634 if oid.len() != EPHEMERAL_PREFIX_LEN || !oid.bytes().all(|byte| byte.is_ascii_hexdigit()) {
1635 return None;
1636 }
1637 git_repo
1638 .revparse_single(oid)
1639 .ok()?
1640 .peel_to_commit()
1641 .ok()
1642 .map(|commit| commit.id().to_string())
1643}
1644
1645/// Build, without writing, the switch-path projection commit (RFC §8.2).
1646///

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