Diff
src/git.rs | 20 +++++++++++++++-----
src/database/indexer.rs | 8 ++++++--
src/database/schema/commit.rs | 9 ++++++---
3 files changed, 20 insertions(+), 17 deletions(-)
@@ -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<T: Copy> SmallVec<T> {
#[allow(clippy::type_complexity)]
fn iter(
&self,
) -> Either<std::iter::Empty<T>, Either<std::iter::Once<T>, Copied<std::slice::Iter<T>>>> {
@@ -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<Item = &BStr> {
@@ -851,7 +851,7 @@
}
pub fn body(&self) -> &BStr {
&self.body
self.body
}
}
@@ -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,
@@ -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<Self, anyhow::Error> {
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,
},
})