Skip to content

Commit 88752d3

Browse files
committed
refactor - cleanup UI types in but-workspace a bit
1 parent 099957a commit 88752d3

File tree

6 files changed

+514
-509
lines changed

6 files changed

+514
-509
lines changed

crates/but-api/src/commands/workspace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn ref_metadata_toml(project: &Project) -> anyhow::Result<VirtualBranchesTomlMet
2828
#[api_cmd]
2929
#[tauri::command(async)]
3030
#[instrument(err(Debug))]
31-
pub fn head_info(project_id: ProjectId) -> Result<but_workspace::ref_info::ui::RefInfo, Error> {
31+
pub fn head_info(project_id: ProjectId) -> Result<but_workspace::ui::ref_info::RefInfo, Error> {
3232
let project = gitbutler_project::get(project_id)?;
3333
let ctx = CommandContext::open(&project, AppSettings::load_from_default_path_creating()?)?;
3434
let repo = ctx.gix_repo_for_merging_non_persisting()?;
@@ -42,7 +42,7 @@ pub fn head_info(project_id: ProjectId) -> Result<but_workspace::ref_info::ui::R
4242
},
4343
)
4444
.map_err(Into::into)
45-
.and_then(|info| but_workspace::ref_info::ui::RefInfo::for_ui(info, &repo).map_err(Into::into))
45+
.and_then(|info| but_workspace::ui::ref_info::RefInfo::for_ui(info, &repo).map_err(Into::into))
4646
}
4747

4848
#[api_cmd]

crates/but-workspace/src/changeset.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
77
use crate::{
88
RefInfo,
9-
ref_info::{
10-
ui,
11-
ui::{LocalCommit, LocalCommitRelation},
9+
ui::{
10+
PushStatus,
11+
ref_info::{LocalCommit, LocalCommitRelation},
1212
},
13-
ui::PushStatus,
1413
};
1514
use bstr::{BStr, BString, ByteSlice, ByteVec};
1615
use but_core::{ChangeState, commit::TreeKind};
@@ -94,7 +93,7 @@ impl RefInfo {
9493
repo,
9594
upstream_commits.iter().filter_map(|id| {
9695
but_core::Commit::from_id(id.attach(repo))
97-
.map(ui::Commit::from)
96+
.map(crate::ui::ref_info::Commit::from)
9897
.ok()
9998
}),
10099
cost_info,
@@ -262,7 +261,7 @@ impl PushStatus {
262261

263262
fn changeset_identifier(
264263
repo: &gix::Repository,
265-
commit: Option<&ui::Commit>,
264+
commit: Option<&crate::ui::ref_info::Commit>,
266265
elapsed: &mut Duration,
267266
) -> anyhow::Result<Option<Identifier>> {
268267
let Some(commit) = commit else {
@@ -296,7 +295,7 @@ enum ChangeId {
296295

297296
fn lookup_similar<'a>(
298297
map: &'a Identity,
299-
commit: &ui::Commit,
298+
commit: &crate::ui::ref_info::Commit,
300299
expensive: Option<&Identifier>,
301300
change_id: ChangeId,
302301
) -> Option<&'a gix::ObjectId> {
@@ -312,7 +311,7 @@ fn lookup_similar<'a>(
312311
/// Returns the fully-loaded commits suitable to be passed to UI, to have better re-use.
313312
fn create_similarity_lut(
314313
repo: &gix::Repository,
315-
commits: impl Iterator<Item = impl Borrow<ui::Commit>>,
314+
commits: impl Iterator<Item = impl Borrow<crate::ui::ref_info::Commit>>,
316315
(max_commits, num_tracked_files): (usize, usize),
317316
expensive: bool,
318317
) -> anyhow::Result<Identity> {
@@ -633,7 +632,7 @@ enum Identifier {
633632
ChangesetId(ChangesetID),
634633
}
635634

636-
fn commit_data_id(c: &ui::Commit) -> anyhow::Result<Identifier> {
635+
fn commit_data_id(c: &crate::ui::ref_info::Commit) -> anyhow::Result<Identifier> {
637636
let mut hasher = gix::hash::hasher(gix::hash::Kind::Sha1);
638637

639638
let gix::actor::Signature {

crates/but-workspace/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ pub struct RefInfo {
222222
pub struct AncestorWorkspaceCommit {
223223
/// The commits along the first parent that are between the managed workspace reference and the managed workspace commit.
224224
/// The vec is never empty.
225-
pub commits_outside: Vec<ref_info::ui::Commit>,
225+
pub commits_outside: Vec<ui::ref_info::Commit>,
226226
/// The index of the segment that actually holds the managed workspace commit.
227227
pub segment_with_managed_commit: SegmentIndex,
228228
/// The index of the workspace commit within the `commits` array in its parent segment.

0 commit comments

Comments
 (0)