|
1 | 1 | use bstr::{BString, ByteSlice}; |
2 | | -use gitbutler_commit::commit_ext::CommitExt as _; |
3 | 2 | use gix::date::parse::TimeBuf; |
4 | 3 | use serde::Serialize; |
5 | 4 |
|
@@ -121,15 +120,20 @@ but_schemars::register_sdk_type!(Commit); |
121 | 120 | impl TryFrom<gix::Commit<'_>> for Commit { |
122 | 121 | type Error = anyhow::Error; |
123 | 122 | fn try_from(commit: gix::Commit<'_>) -> Result<Self, Self::Error> { |
| 123 | + let commit_id = commit.id; |
| 124 | + let commit = commit.decode()?; |
| 125 | + let headers = but_core::commit::Headers::try_from_commit_headers(|| commit.extra_headers()); |
124 | 126 | Ok(Commit { |
125 | | - id: commit.id, |
126 | | - parent_ids: commit.parent_ids().map(|id| id.detach()).collect(), |
127 | | - message: commit.message_raw_sloppy().into(), |
128 | | - has_conflicts: false, |
129 | | - state: CommitState::LocalAndRemote(commit.id), |
| 127 | + id: commit_id, |
| 128 | + parent_ids: commit.parents().collect(), |
| 129 | + message: commit.message.to_owned(), |
| 130 | + has_conflicts: headers.as_ref().is_some_and(|hdr| hdr.is_conflicted()), |
| 131 | + state: CommitState::LocalAndRemote(commit_id), |
130 | 132 | created_at: i128::from(commit.time()?.seconds) * 1000, |
131 | 133 | author: commit.author()?.into(), |
132 | | - change_id: commit.change_id().map(|id| id.to_string()), |
| 134 | + change_id: headers |
| 135 | + .and_then(|headers| headers.change_id) |
| 136 | + .map(|id| id.to_string()), |
133 | 137 | gerrit_review_url: None, |
134 | 138 | }) |
135 | 139 | } |
|
0 commit comments