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)
| 33 | /// `refs/heads/*` (including the degraded fallback), tags, notes, and any |
| 34 | /// other namespace — is refused. |
| 35 | pub 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). |
| 56 | pub fn is_wip_ref(name: &str) -> bool { |
no test coverage detected