MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / get_file_content

Function get_file_content

atomic-cli/src/commands/git/parallel.rs:4119–4139  ·  view source on GitHub ↗

Get file content from a git tree.

(git_repo: &GitRepository, tree: &Tree, path: &str)

Source from the content-addressed store, hash-verified

4117
4118/// Get file content from a git tree.
4119fn 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.
4142fn parse_commit_message(message: &str) -> (String, Option<String>) {

Callers 2

parse_diff_filesFunction · 0.85

Calls 4

get_pathMethod · 0.45
kindMethod · 0.45
idMethod · 0.45
contentMethod · 0.45

Tested by

no test coverage detected