Get file content from a git tree.
(git_repo: &GitRepository, tree: &Tree, path: &str)
| 4117 | |
| 4118 | /// Get file content from a git tree. |
| 4119 | fn get_file_content(git_repo: &GitRepository, tree: &Tree, path: &str) -> CliResult<Vec<u8>> { |
| 4120 | let entry = tree |
| 4121 | .get_path(Path::new(path)) |
| 4122 | .map_err(|e| CliError::GitError { |
| 4123 | message: format!("Path not found in tree: {}", e), |
| 4124 | })?; |
| 4125 | |
| 4126 | if entry.kind() != Some(ObjectType::Blob) { |
| 4127 | return Err(CliError::GitError { |
| 4128 | message: "Not a file".to_string(), |
| 4129 | }); |
| 4130 | } |
| 4131 | |
| 4132 | let blob = git_repo |
| 4133 | .find_blob(entry.id()) |
| 4134 | .map_err(|e| CliError::GitError { |
| 4135 | message: format!("Failed to find blob: {}", e), |
| 4136 | })?; |
| 4137 | |
| 4138 | Ok(blob.content().to_vec()) |
| 4139 | } |
| 4140 | |
| 4141 | /// Parse a git commit message into subject and description. |
| 4142 | fn parse_commit_message(message: &str) -> (String, Option<String>) { |
no test coverage detected