Get file content from a git tree.
(git_repo: &GitRepository, tree: &Tree, path: &str)
| 4516 | |
| 4517 | /// Get file content from a git tree. |
| 4518 | fn get_file_content(git_repo: &GitRepository, tree: &Tree, path: &str) -> CliResult<Vec<u8>> { |
| 4519 | let entry = tree |
| 4520 | .get_path(Path::new(path)) |
| 4521 | .map_err(|e| CliError::GitError { |
| 4522 | message: format!("Path not found in tree: {}", e), |
| 4523 | })?; |
| 4524 | |
| 4525 | if entry.kind() != Some(ObjectType::Blob) { |
| 4526 | return Err(CliError::GitError { |
| 4527 | message: "Not a file".to_string(), |
| 4528 | }); |
| 4529 | } |
| 4530 | |
| 4531 | let blob = git_repo |
| 4532 | .find_blob(entry.id()) |
| 4533 | .map_err(|e| CliError::GitError { |
| 4534 | message: format!("Failed to find blob: {}", e), |
| 4535 | })?; |
| 4536 | |
| 4537 | Ok(blob.content().to_vec()) |
| 4538 | } |
| 4539 | |
| 4540 | /// Parse a git commit message into subject and description. |
| 4541 | fn parse_commit_message(message: &str) -> (String, Option<String>) { |
no test coverage detected