Skip to content

Commit 1478238

Browse files
committed
Fix failing clippy lints
1 parent 91a9d84 commit 1478238

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/database/indexer.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,12 @@ fn branch_index_update(
251251
}
252252

253253
let commit = rev.object()?;
254-
let author = commit.author()?;
255-
let committer = commit.committer()?;
254+
let oid = commit.id;
255+
let commit = commit.decode()?;
256+
let author = commit.author();
257+
let committer = commit.committer();
256258

257-
Commit::new(&commit, author, committer)?.insert(
259+
Commit::new(oid, &commit, author, committer)?.insert(
258260
&commit_tree,
259261
tree_len + i,
260262
&mut batch,

src/database/schema/commit.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::sync::Arc;
22

33
use anyhow::Context;
4-
use gix::{actor::SignatureRef, ObjectId};
4+
use gix::{actor::SignatureRef, objs::CommitRef, ObjectId};
55
use rkyv::{Archive, Serialize};
66
use rocksdb::{IteratorMode, ReadOptions, WriteBatch};
77
use time::{OffsetDateTime, UtcOffset};
@@ -25,18 +25,19 @@ pub struct Commit {
2525

2626
impl Commit {
2727
pub fn new(
28-
commit: &gix::Commit<'_>,
28+
oid: ObjectId,
29+
commit: &CommitRef<'_>,
2930
author: SignatureRef<'_>,
3031
committer: SignatureRef<'_>,
3132
) -> Result<Self, anyhow::Error> {
32-
let message = commit.message()?;
33+
let message = commit.message();
3334

3435
Ok(Self {
3536
summary: message.summary().to_string(),
3637
message: message.body.map(ToString::to_string).unwrap_or_default(),
3738
committer: committer.try_into()?,
3839
author: author.try_into()?,
39-
hash: match commit.id().detach() {
40+
hash: match oid {
4041
ObjectId::Sha1(d) => d,
4142
},
4243
})

src/git.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -739,11 +739,11 @@ impl<'a> TryFrom<SignatureRef<'a>> for CommitUser<'a> {
739739

740740
impl CommitUser<'_> {
741741
pub fn name(&self) -> &BStr {
742-
&self.name
742+
self.name
743743
}
744744

745745
pub fn email(&self) -> &BStr {
746-
&self.email
746+
self.email
747747
}
748748

749749
pub fn time(&self) -> OffsetDateTime {
@@ -785,6 +785,7 @@ enum SmallVec<T> {
785785
}
786786

787787
impl<T: Copy> SmallVec<T> {
788+
#[allow(clippy::type_complexity)]
788789
fn iter(
789790
&self,
790791
) -> Either<std::iter::Empty<T>, Either<std::iter::Once<T>, Copied<std::slice::Iter<T>>>> {
@@ -805,17 +806,16 @@ impl<'a> CommitInner<'a> {
805806
committer: CommitUser::try_from(commit.committer)?,
806807
oid,
807808
tree: commit.tree,
808-
parents: commit
809-
.parents
810-
.into_inner()
811-
.map(|[v]| SmallVec::One(v))
812-
.unwrap_or_else(|inner| {
809+
parents: commit.parents.into_inner().map_or_else(
810+
|inner| {
813811
if inner.is_empty() {
814812
SmallVec::None
815813
} else {
816814
SmallVec::Many(inner.into_vec())
817815
}
818-
}),
816+
},
817+
|[v]| SmallVec::One(v),
818+
),
819819

820820
summary: message.summary(),
821821
body: message.body.unwrap_or_else(|| BStr::new("")),
@@ -839,7 +839,7 @@ impl CommitInner<'_> {
839839
}
840840

841841
pub fn tree(&self) -> &BStr {
842-
&self.tree
842+
self.tree
843843
}
844844

845845
pub fn parents(&self) -> impl Iterator<Item = &BStr> {
@@ -851,7 +851,7 @@ impl CommitInner<'_> {
851851
}
852852

853853
pub fn body(&self) -> &BStr {
854-
&self.body
854+
self.body
855855
}
856856
}
857857

0 commit comments

Comments
 (0)