From 99fc7a7b32ade3852010e6b54cf183ec9e5ccc8b Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sat, 28 Mar 2020 19:47:25 +0100 Subject: [PATCH] fix test --- asyncgit/src/sync/diff.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/asyncgit/src/sync/diff.rs b/asyncgit/src/sync/diff.rs index 73d7b270..19096f31 100644 --- a/asyncgit/src/sync/diff.rs +++ b/asyncgit/src/sync/diff.rs @@ -185,15 +185,19 @@ pub fn get_diff(repo_path: &str, p: String, stage: bool) -> Diff { fn new_file_content(path: &Path) -> String { if let Ok(meta) = fs::symlink_metadata(path) { if meta.file_type().is_symlink() { - fs::read_link(path).unwrap().to_str().unwrap().to_string() - } else { - "file not found".to_string() + return fs::read_link(path) + .unwrap() + .to_str() + .unwrap() + .to_string(); + } else if meta.file_type().is_file() { + if let Ok(content) = fs::read_to_string(path) { + return content; + } } - } else if let Ok(content) = fs::read_to_string(path) { - content - } else { - "file not found".to_string() } + + "file not found".to_string() } #[cfg(test)]