diff options
Diffstat (limited to 'src/project/git.rs')
-rw-r--r-- | src/project/git.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/project/git.rs b/src/project/git.rs index 759f632..6c8f329 100644 --- a/src/project/git.rs +++ b/src/project/git.rs @@ -5,7 +5,9 @@ use std::io; use std::{path::PathBuf, time::Duration}; use tracing::{debug, warn}; -use super::{Error, Preview, ProjectParser, Timestamp}; +use crate::{Error, Result}; + +use super::{Preview, ProjectParser, Timestamp}; #[derive(Debug, Clone)] pub struct GitMatcher; @@ -30,7 +32,7 @@ pub struct GitProject { } impl GitProject { - fn new(path_buf: PathBuf) -> Result<Self, Error> { + fn new(path_buf: PathBuf) -> Result<Self> { let repo = Repository::open(&path_buf)?; let latest_commit = Self::get_timestamp(&repo); Ok(Self { @@ -49,7 +51,7 @@ impl GitProject { } } - fn latest_commit(repository: &Repository) -> Result<u64, git2::Error> { + fn latest_commit(repository: &Repository) -> Result<u64> { let mut branches = repository.branches(Some(BranchType::Local))?; branches.try_fold(0, |latest, branch| { let (branch, _) = branch?; @@ -62,6 +64,7 @@ impl GitProject { .revparse_single(name)? .peel_to_commit() .map(|c| (c.time().seconds() as u64).max(latest)) + .map_err(Into::into) }) } } @@ -76,7 +79,7 @@ impl Timestamp for GitProject { impl Preview for GitProject { type Error = Error; - fn preview(&self) -> Result<(), Self::Error> { + fn preview(&self) -> Result<()> { let config = onefetch::cli::Config { input: self.path_buf.to_owned(), include_hidden: true, @@ -99,7 +102,7 @@ impl AsRef<PathBuf> for GitProject { impl TryFrom<PathBuf> for GitProject { type Error = Error; - fn try_from(value: PathBuf) -> Result<Self, Self::Error> { + fn try_from(value: PathBuf) -> Result<Self> { Self::new(value) } } @@ -107,7 +110,7 @@ impl TryFrom<PathBuf> for GitProject { impl TryFrom<DirEntry> for GitProject { type Error = Error; - fn try_from(value: DirEntry) -> Result<Self, Self::Error> { + fn try_from(value: DirEntry) -> Result<Self> { Self::new(value.into_path()) } } |