Function
get_commit_hash_default_impl
(repository_root_path: &str)
Source from the content-addressed store, hash-verified
| 154 | } |
| 155 | |
| 156 | fn get_commit_hash_default_impl(repository_root_path: &str) -> Result<String> { |
| 157 | let repo = Repository::open(repository_root_path).context(format!( |
| 158 | "Failed to open repository at path: {repository_root_path}" |
| 159 | ))?; |
| 160 | |
| 161 | let commit_hash = repo |
| 162 | .head() |
| 163 | .and_then(|head| head.peel_to_commit()) |
| 164 | .context("Failed to get HEAD commit")? |
| 165 | .id() |
| 166 | .to_string(); |
| 167 | Ok(commit_hash) |
| 168 | } |
| 169 | |
| 170 | #[cfg(test)] |
| 171 | mod tests { |