diff --git a/src/git/log.rs b/src/git/log.rs index 6aaf3ed..85ca11f 100644 --- a/src/git/log.rs +++ b/src/git/log.rs @@ -38,7 +38,7 @@ impl Log for SocialRepo { Ok(Box::new( git_revwalk - .filter_map(move |idres| idres.map(|id| self.repo.find_commit(id.clone())).ok()) + .filter_map(move |idres| idres.map(|id| self.repo.find_commit(id)).ok()) .flatten() .map(|c| c.into()) .map(move |c: SocialCommit| if short { c.oneline() } else { c }) @@ -59,7 +59,7 @@ impl Log for SocialRepo { revwalk.set_sorting(git2::Sort::REVERSE | git2::Sort::TOPOLOGICAL)?; revwalk.push_head()?; revwalk - .filter_map(move |idres| idres.map(|id| self.repo.find_commit(id.clone())).ok()) + .filter_map(move |idres| idres.map(|id| self.repo.find_commit(id)).ok()) .take(1) .next() .map(|r| { @@ -69,7 +69,7 @@ impl Log for SocialRepo { .map(|c| c.into()) }) .ok_or(SocialError { - message: format!("Repo doesn't contain any commits!") + message: "Repo doesn't contain any commits!".to_string() })? } } diff --git a/src/git/repo.rs b/src/git/repo.rs index 38a9187..449e291 100644 --- a/src/git/repo.rs +++ b/src/git/repo.rs @@ -6,7 +6,7 @@ pub struct SocialRepo { pub repo: Repository, } -impl<'repo> SocialRepo { +impl SocialRepo { pub fn new(path: &str) -> Result { Repository::open(path) .map(|repo| Self { repo }) diff --git a/src/git/tree.rs b/src/git/tree.rs index 2936f4b..f622859 100644 --- a/src/git/tree.rs +++ b/src/git/tree.rs @@ -25,7 +25,7 @@ impl LsTree for SocialRepo { self.get_tree(rev)? } else { self.get_tree(rev) - .and_then(|t| t.get_path(&path)) + .and_then(|t| t.get_path(path)) .and_then(|entry: TreeEntry| self.repo.find_tree(entry.id()))? }; @@ -37,9 +37,9 @@ impl LsTree for SocialRepo { self.repo .revparse_single(&format!("{}", entry.id())) .map(|obj: Object| { - obj.as_blob().map(|b: &Blob| { + if let Some(b) = obj.as_blob() { files.push(into_social_tree_entry(entry, b.content().len())) - }); + }; }) .unwrap_or(()); } @@ -53,7 +53,7 @@ impl LsTree for SocialRepo { fn show_file(&self, rev: &str, path: &Path) -> Result { self.get_tree(rev) - .and_then(|t| t.get_path(&path)) + .and_then(|t| t.get_path(path)) .and_then(|entry: TreeEntry| match entry.kind() { Some(ObjectType::Blob) => self .repo