diff --git a/asyncgit/src/sync/commits_info.rs b/asyncgit/src/sync/commits_info.rs index 0c31b4705b..d1727cdfdd 100644 --- a/asyncgit/src/sync/commits_info.rs +++ b/asyncgit/src/sync/commits_info.rs @@ -3,12 +3,9 @@ use std::fmt::Display; use super::RepoPath; use crate::{ error::Result, - sync::{ - commit_details::get_author_of_commit, - repository::{gix_repo, repo}, - }, + sync::repository::{gix_repo, repo}, }; -use git2::{Commit, Error, Oid}; +use git2::Oid; use scopetime::scope_time; use unicode_truncate::UnicodeTruncateStr; @@ -132,34 +129,34 @@ pub fn get_commits_info( ) -> Result> { scope_time!("get_commits_info"); - let repo = repo(repo_path)?; - let mailmap = repo.mailmap()?; - - let commits = ids - .iter() - .map(|id| repo.find_commit((*id).into())) - .collect::, Error>>()? - .into_iter(); - - let res = commits - .map(|c: Commit| { - let message = get_message(&c, Some(message_length_limit)); - let author = get_author_of_commit(&c, &mailmap) - .name() - .map_or_else( - || String::from(""), - String::from, - ); - CommitInfo { + let repo: gix::Repository = gix_repo(repo_path)?; + let mailmap = repo.open_mailmap(); + + ids.iter() + .map(|id| -> Result<_> { + let commit = repo.find_commit(*id)?; + let commit_ref = commit.decode()?; + + let message = gix_get_message( + &commit_ref, + Some(message_length_limit), + ); + + let author = commit_ref.author(); + + let author = mailmap.try_resolve(author).map_or_else( + || author.name.into(), + |signature| signature.name, + ); + + Ok(CommitInfo { message, - author, - time: c.time().seconds(), - id: CommitId(c.id()), - } + author: author.to_string(), + time: commit_ref.time().seconds, + id: *id, + }) }) - .collect::>(); - - Ok(res) + .collect() } /// diff --git a/asyncgit/src/sync/tags.rs b/asyncgit/src/sync/tags.rs index f2193b2193..7571c2d51a 100644 --- a/asyncgit/src/sync/tags.rs +++ b/asyncgit/src/sync/tags.rs @@ -1,5 +1,8 @@ use super::{get_commits_info, CommitId, RepoPath}; -use crate::{error::Result, sync::repository::repo}; +use crate::{ + error::Result, + sync::{gix_repo, repository::repo}, +}; use scopetime::scope_time; use std::collections::{BTreeMap, HashMap, HashSet}; @@ -58,9 +61,7 @@ pub fn get_tags(repo_path: &RepoPath) -> Result { } }; - let gix_repo: gix::Repository = - gix::ThreadSafeRepository::discover_with_environment_overrides(repo_path.gitpath()) - .map(Into::into)?; + let gix_repo: gix::Repository = gix_repo(repo_path)?; let platform = gix_repo.references()?; for mut reference in (platform.tags()?).flatten() { let commit = reference.peel_to_commit();