From 1478238f03a3ed085dea9750016e8967d649786a Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Wed, 08 Jan 2025 15:43:47 +0700 Subject: [PATCH] Fix failing clippy lints --- src/git.rs | 20 +++++++++++++++----- src/database/indexer.rs | 8 ++++++-- src/database/schema/commit.rs | 9 ++++++--- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/git.rs b/src/git.rs index a0cf052..f6f92f8 100644 --- a/src/git.rs +++ a/src/git.rs @@ -739,11 +739,11 @@ impl CommitUser<'_> { pub fn name(&self) -> &BStr { - &self.name + self.name } pub fn email(&self) -> &BStr { - &self.email + self.email } pub fn time(&self) -> OffsetDateTime { @@ -785,6 +785,7 @@ } impl SmallVec { + #[allow(clippy::type_complexity)] fn iter( &self, ) -> Either, Either, Copied>>> { @@ -805,17 +806,16 @@ committer: CommitUser::try_from(commit.committer)?, oid, tree: commit.tree, - parents: commit - .parents - .into_inner() - .map(|[v]| SmallVec::One(v)) - .unwrap_or_else(|inner| { + parents: commit.parents.into_inner().map_or_else( + |inner| { if inner.is_empty() { SmallVec::None } else { SmallVec::Many(inner.into_vec()) } - }), + }, + |[v]| SmallVec::One(v), + ), summary: message.summary(), body: message.body.unwrap_or_else(|| BStr::new("")), @@ -839,7 +839,7 @@ } pub fn tree(&self) -> &BStr { - &self.tree + self.tree } pub fn parents(&self) -> impl Iterator { @@ -851,7 +851,7 @@ } pub fn body(&self) -> &BStr { - &self.body + self.body } } diff --git a/src/database/indexer.rs b/src/database/indexer.rs index 5ca633e..f4743ce 100644 --- a/src/database/indexer.rs +++ a/src/database/indexer.rs @@ -251,10 +251,12 @@ } let commit = rev.object()?; - let author = commit.author()?; - let committer = commit.committer()?; + let oid = commit.id; + let commit = commit.decode()?; + let author = commit.author(); + let committer = commit.committer(); - Commit::new(&commit, author, committer)?.insert( + Commit::new(oid, &commit, author, committer)?.insert( &commit_tree, tree_len + i, &mut batch, diff --git a/src/database/schema/commit.rs b/src/database/schema/commit.rs index 4cd97af..6ebbb4a 100644 --- a/src/database/schema/commit.rs +++ a/src/database/schema/commit.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use anyhow::Context; -use gix::{actor::SignatureRef, ObjectId}; +use gix::{actor::SignatureRef, objs::CommitRef, ObjectId}; use rkyv::{Archive, Serialize}; use rocksdb::{IteratorMode, ReadOptions, WriteBatch}; use time::{OffsetDateTime, UtcOffset}; @@ -25,18 +25,19 @@ impl Commit { pub fn new( - commit: &gix::Commit<'_>, + oid: ObjectId, + commit: &CommitRef<'_>, author: SignatureRef<'_>, committer: SignatureRef<'_>, ) -> Result { - let message = commit.message()?; + let message = commit.message(); Ok(Self { summary: message.summary().to_string(), message: message.body.map(ToString::to_string).unwrap_or_default(), committer: committer.try_into()?, author: author.try_into()?, - hash: match commit.id().detach() { + hash: match oid { ObjectId::Sha1(d) => d, }, }) -- rgit 0.1.4