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)
| 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. |
| 1444 | pub(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 | /// |
no test coverage detected