Skip to content

Commit ef65c5f

Browse files
committed
address auto-review
1 parent 427efb0 commit ef65c5f

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

crates/but-workspace/src/branch_details.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::collections::HashSet;
22

33
use anyhow::Context as _;
44
use but_core::RefMetadata;
5-
use gitbutler_commit::commit_ext::CommitExt as _;
65
use gix::{
76
date::parse::TimeBuf, prelude::ObjectIdExt as _, reference::Category, remote::Direction,
87
};
@@ -185,8 +184,10 @@ fn upstream_commits_gix(
185184
for info in traversal {
186185
let info = info?;
187186
let commit = info.id().object()?.into_commit();
188-
let change_id = commit.change_id().map(|id| id.to_string());
189187
let commit = commit.decode()?;
188+
let change_id =
189+
but_core::commit::Headers::try_from_commit_headers(|| commit.extra_headers())
190+
.and_then(|hdr| hdr.change_id.map(|id| id.to_string()));
190191
let author: ui::Author = commit.author()?.into();
191192
let committer: ui::Author = commit.committer()?.into();
192193
authors.insert(author.clone());

crates/but-workspace/src/ui/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use bstr::{BString, ByteSlice};
2-
use gitbutler_commit::commit_ext::CommitExt as _;
32
use gix::date::parse::TimeBuf;
43
use serde::Serialize;
54

@@ -121,15 +120,20 @@ but_schemars::register_sdk_type!(Commit);
121120
impl TryFrom<gix::Commit<'_>> for Commit {
122121
type Error = anyhow::Error;
123122
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());
124126
Ok(Commit {
125-
id: commit.id,
126-
parent_ids: commit.parent_ids().map(|id| id.detach()).collect(),
127-
message: commit.message_raw_sloppy().into(),
127+
id: commit_id,
128+
parent_ids: commit.parents().collect(),
129+
message: commit.message.to_owned(),
128130
has_conflicts: false,
129-
state: CommitState::LocalAndRemote(commit.id),
131+
state: CommitState::LocalAndRemote(commit_id),
130132
created_at: i128::from(commit.time()?.seconds) * 1000,
131133
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()),
133137
gerrit_review_url: None,
134138
})
135139
}

crates/but/src/command/legacy/status/json.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@ pub(super) fn build_workspace_status_json(
567567
created_at: status_ctx.common_merge_base_data.created_at,
568568
message: status_ctx.common_merge_base_data.message.clone().into(),
569569
author,
570+
// This is a synthetic upstream commit used only to reuse
571+
// `Commit::from_upstream_commit()`. Legacy status JSON does not
572+
// expose change-ids, so dropping it here is fine.
570573
change_id: None,
571574
},
572575
None,
@@ -584,6 +587,9 @@ pub(super) fn build_workspace_status_json(
584587
created_at: upstream.created_at,
585588
message: upstream.message.clone().into(),
586589
author: upstream_author,
590+
// This is a synthetic upstream commit used only to reuse
591+
// `Commit::from_upstream_commit()`. Legacy status JSON does not
592+
// expose change-ids, so dropping it here is fine.
587593
change_id: None,
588594
},
589595
None,
@@ -616,6 +622,10 @@ pub(super) fn build_workspace_status_json(
616622
created_at: remote_commit.created_at as i128,
617623
message: remote_commit.description.clone().into(),
618624
author,
625+
// This is a synthetic upstream commit used
626+
// only to reuse `Commit::from_upstream_commit()`.
627+
// Legacy status JSON does not expose
628+
// change-ids, so dropping it here is fine.
619629
change_id: None,
620630
},
621631
None,

0 commit comments

Comments
 (0)