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