Skip to content

Commit 6ed60c4

Browse files
committed
Implement From<gix::ObjectId> for CommitId
1 parent 534da90 commit 6ed60c4

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

asyncgit/src/sync/commits_info.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ impl From<Oid> for CommitId {
8484
}
8585
}
8686

87+
impl From<gix::ObjectId> for CommitId {
88+
fn from(object_id: gix::ObjectId) -> Self {
89+
#[allow(clippy::expect_used)]
90+
let oid = Oid::from_bytes(object_id.as_bytes()).expect("`Oid::from_bytes(object_id.as_bytes())` is expected to never fail");
91+
92+
Self::new(oid)
93+
}
94+
}
95+
8796
///
8897
#[derive(Debug, Clone)]
8998
pub struct CommitInfo {

asyncgit/src/sync/logwalker.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,7 @@ impl<'a> LogWalkerWithoutFilter<'a> {
161161
let mut count = 0_usize;
162162

163163
while let Some(Ok(info)) = self.walk.next() {
164-
let bytes = info.id.as_bytes();
165-
let commit_id: CommitId = Oid::from_bytes(bytes)?.into();
166-
167-
out.push(commit_id);
164+
out.push(info.id.into());
168165

169166
count += 1;
170167

0 commit comments

Comments
 (0)