Skip to content

Commit f667a9b

Browse files
committed
Implement stack_v3 as hypothetical substitute for stack, using new head_info().
Also, refactor `stacks()` related code into its own module to shrink `lib.rs`.
1 parent 3bbcc3f commit f667a9b

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

crates/but-workspace/src/branch_details.rs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use but_core::RefMetadata;
66
use gitbutler_command_context::CommandContext;
77
use gitbutler_error::error::Code;
88
use gitbutler_oxidize::OidExt;
9+
use gix::reference::Category;
910
use gix::remote::Direction;
1011
use std::collections::HashSet;
1112
use std::path::Path;
@@ -145,7 +146,8 @@ pub fn branch_details(
145146
/// This branch is assumed to not be in the workspace, but it will still be assumed to want to integrate with the workspace target reference if set.
146147
///
147148
/// ### Implementation
148-
#[allow(unused_variables)]
149+
///
150+
/// Note that not all possible [`PushStatus`] status are respected.
149151
pub fn branch_details_v3(
150152
repo: &gix::Repository,
151153
name: &gix::refs::FullNameRef,
@@ -197,24 +199,26 @@ pub fn branch_details_v3(
197199
)?;
198200
// TODO: have a test that shows why this must/should be last. Then maybe make it easy to do
199201
// the right thing whenever the mergebase with the integration branch is needed.
200-
merge_bases.last().map(|id| id.detach())
202+
merge_bases
203+
.last()
204+
.map(|id| id.detach())
205+
.with_context(|| format!("No merge-base found between {name} and the integration branch {integration_ref_name}", name = name.as_bstr()))?
201206
};
202207

203-
todo!()
204-
// Ok(ui::BranchDetails {
205-
// name: name.as_bstr().into(),
206-
// remote_tracking_branch: remote_tracking_branch.map(|b| b.name().as_bstr().to_owned()),
207-
// description: meta.description.clone(),
208-
// pr_number: meta.review.pull_request,
209-
// review_id: meta.review.review_id.clone(),
210-
// base_commit: todo!(),
211-
// push_status,
212-
// last_updated_at: todo!(),
213-
// authors: todo!(),
214-
// is_conflicted: todo!(),
215-
// commits: todo!(),
216-
// upstream_commits: todo!(),
217-
// tip: branch_target_id.detach(),
218-
// is_remote_head: name.category() == Some(Category::RemoteBranch),
219-
// })
208+
Ok(ui::BranchDetails {
209+
name: name.as_bstr().into(),
210+
remote_tracking_branch: remote_tracking_branch.map(|b| b.name().as_bstr().to_owned()),
211+
description: meta.description.clone(),
212+
pr_number: meta.review.pull_request,
213+
review_id: meta.review.review_id.clone(),
214+
base_commit,
215+
push_status,
216+
last_updated_at: todo!(),
217+
authors: todo!(),
218+
is_conflicted: todo!(),
219+
commits: todo!(),
220+
upstream_commits: todo!(),
221+
tip: branch_target_id.detach(),
222+
is_remote_head: name.category() == Some(Category::RemoteBranch),
223+
})
220224
}

0 commit comments

Comments
 (0)