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

Function is_transferable_ref

atomic-repository/src/git_binding/transport.rs:35–53  ·  view source on GitHub ↗

Whether `name` is a ref this transport may transfer. The allowlist is exactly the create-only binding namespace with a two-hex-character shard and a 64-hex id. Everything else — WIP refs, `refs/heads/*` (including the degraded fallback), tags, notes, and any other namespace — is refused.

(name: &str)

Source from the content-addressed store, hash-verified

33/// `refs/heads/*` (including the degraded fallback), tags, notes, and any
34/// other namespace — is refused.
35pub fn is_transferable_ref(name: &str) -> bool {
36 let Some(rest) = name.strip_prefix(BINDING_REF_PREFIX) else {
37 return false;
38 };
39 let mut segments = rest.split('/');
40 match (segments.next(), segments.next(), segments.next()) {
41 (Some(shard), Some(id), None) => {
42 shard.len() == 2
43 && shard
44 .bytes()
45 .all(|byte| byte.is_ascii_digit() || (b'a'..=b'f').contains(&byte))
46 && id.len() == 64
47 && id
48 .bytes()
49 .all(|byte| byte.is_ascii_digit() || (b'a'..=b'f').contains(&byte))
50 }
51 _ => false,
52 }
53}
54
55/// Whether `name` is a local WIP recovery ref (never transferable).
56pub fn is_wip_ref(name: &str) -> bool {

Callers 2

Calls 5

nextMethod · 0.45
lenMethod · 0.45
allMethod · 0.45
bytesMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected