remove useless indirection when getting index size

This commit is contained in:
Kiril Videlov 2024-07-07 23:22:58 +02:00
parent 569d282700
commit c62c43ed6c
No known key found for this signature in database
GPG Key ID: A4C733025427C471
2 changed files with 4 additions and 8 deletions

View File

@ -138,15 +138,9 @@ pub trait RepoActions {
where
P: AsRef<std::path::Path>;
fn get_head(&self) -> Result<git2::Reference>;
fn git_index_size(&self) -> Result<usize>;
}
impl RepoActions for ProjectRepo {
fn git_index_size(&self) -> Result<usize> {
let head = self.git_repository.index()?.len();
Ok(head)
}
fn get_head(&self) -> Result<git2::Reference> {
let head = self.git_repository.head()?;
Ok(head)

View File

@ -60,8 +60,10 @@ impl App {
let project = self.projects.get(project_id)?;
let project_repository = project_repository::ProjectRepo::open(&project)?;
let size = project_repository
.git_index_size()
.context("failed to get index size")?;
.repo()
.index()
.context("failed to get index size")?
.len();
Ok(size)
}