Get file content from a git tree.
(git_repo: &GitRepository, tree: &Tree, path: &str)
| 3999 | |
| 4000 | /// Get file content from a git tree. |
| 4001 | fn get_file_content(git_repo: &GitRepository, tree: &Tree, path: &str) -> CliResult<Vec<u8>> { |
| 4002 | let entry = tree |
| 4003 | .get_path(Path::new(path)) |
| 4004 | .map_err(|e| CliError::GitError { |
| 4005 | message: format!("Path not found in tree: {}", e), |
| 4006 | })?; |
| 4007 | |
| 4008 | if entry.kind() != Some(ObjectType::Blob) { |
| 4009 | return Err(CliError::GitError { |
| 4010 | message: "Not a file".to_string(), |
| 4011 | }); |
| 4012 | } |
| 4013 | |
| 4014 | let blob = git_repo |
| 4015 | .find_blob(entry.id()) |
| 4016 | .map_err(|e| CliError::GitError { |
| 4017 | message: format!("Failed to find blob: {}", e), |
| 4018 | })?; |
| 4019 | |
| 4020 | Ok(blob.content().to_vec()) |
| 4021 | } |
| 4022 | |
| 4023 | /// Parse a git commit message into subject and description. |
| 4024 | fn parse_commit_message(message: &str) -> (String, Option<String>) { |
no test coverage detected