clippy ftw
This commit is contained in:
parent
ed0c277c4b
commit
cffd91bd5d
3 changed files with 8 additions and 8 deletions
|
@ -38,7 +38,7 @@ impl Log for SocialRepo {
|
||||||
|
|
||||||
Ok(Box::new(
|
Ok(Box::new(
|
||||||
git_revwalk
|
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()
|
.flatten()
|
||||||
.map(|c| c.into())
|
.map(|c| c.into())
|
||||||
.map(move |c: SocialCommit| if short { c.oneline() } else { c })
|
.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.set_sorting(git2::Sort::REVERSE | git2::Sort::TOPOLOGICAL)?;
|
||||||
revwalk.push_head()?;
|
revwalk.push_head()?;
|
||||||
revwalk
|
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)
|
.take(1)
|
||||||
.next()
|
.next()
|
||||||
.map(|r| {
|
.map(|r| {
|
||||||
|
@ -69,7 +69,7 @@ impl Log for SocialRepo {
|
||||||
.map(|c| c.into())
|
.map(|c| c.into())
|
||||||
})
|
})
|
||||||
.ok_or(SocialError {
|
.ok_or(SocialError {
|
||||||
message: format!("Repo doesn't contain any commits!")
|
message: "Repo doesn't contain any commits!".to_string()
|
||||||
})?
|
})?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ pub struct SocialRepo {
|
||||||
pub repo: Repository,
|
pub repo: Repository,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'repo> SocialRepo {
|
impl SocialRepo {
|
||||||
pub fn new(path: &str) -> Result<Self, SocialError> {
|
pub fn new(path: &str) -> Result<Self, SocialError> {
|
||||||
Repository::open(path)
|
Repository::open(path)
|
||||||
.map(|repo| Self { repo })
|
.map(|repo| Self { repo })
|
||||||
|
|
|
@ -25,7 +25,7 @@ impl LsTree for SocialRepo {
|
||||||
self.get_tree(rev)?
|
self.get_tree(rev)?
|
||||||
} else {
|
} else {
|
||||||
self.get_tree(rev)
|
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()))?
|
.and_then(|entry: TreeEntry| self.repo.find_tree(entry.id()))?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ impl LsTree for SocialRepo {
|
||||||
self.repo
|
self.repo
|
||||||
.revparse_single(&format!("{}", entry.id()))
|
.revparse_single(&format!("{}", entry.id()))
|
||||||
.map(|obj: Object| {
|
.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()))
|
files.push(into_social_tree_entry(entry, b.content().len()))
|
||||||
});
|
};
|
||||||
})
|
})
|
||||||
.unwrap_or(());
|
.unwrap_or(());
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ impl LsTree for SocialRepo {
|
||||||
|
|
||||||
fn show_file(&self, rev: &str, path: &Path) -> Result<SocialFileContent, SocialError> {
|
fn show_file(&self, rev: &str, path: &Path) -> Result<SocialFileContent, SocialError> {
|
||||||
self.get_tree(rev)
|
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() {
|
.and_then(|entry: TreeEntry| match entry.kind() {
|
||||||
Some(ObjectType::Blob) => self
|
Some(ObjectType::Blob) => self
|
||||||
.repo
|
.repo
|
||||||
|
|
Loading…
Reference in a new issue