Skip to content

Commit e3554cf

Browse files
committed
feat(status): show target name and commit message for common base
1 parent 0e88845 commit e3554cf

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

crates/but/src/status/mod.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use but_settings::AppSettings;
66
use but_workspace::ui::StackDetails;
77
use colored::{ColoredString, Colorize};
88
use gitbutler_command_context::CommandContext;
9+
use gitbutler_commit::commit_ext::CommitExt;
10+
use gitbutler_oxidize::OidExt;
911
use gitbutler_project::Project;
1012
use std::collections::BTreeMap;
1113
use std::path::Path;
@@ -70,12 +72,20 @@ pub(crate) fn worktree(repo_path: &Path, json: bool, show_files: bool) -> anyhow
7072
ctx,
7173
)?;
7274
}
73-
let common_merge_base = gitbutler_stack::VirtualBranchesHandle::new(ctx.project().gb_dir())
74-
.get_default_target()?
75-
.sha
76-
.to_string()[..7]
77-
.to_string();
78-
println!("◉ {common_merge_base} (common base)");
75+
let stack = gitbutler_stack::VirtualBranchesHandle::new(ctx.project().gb_dir());
76+
let target = stack.get_default_target()?;
77+
let target_name = format!("[{}/{}]", target.branch.remote(), target.branch.branch());
78+
let repo = ctx.gix_repo()?;
79+
let base_commit = repo.find_commit(target.sha.to_gix())?;
80+
let message = base_commit
81+
.message_bstr()
82+
.to_string()
83+
.replace('\n', " ")
84+
.chars()
85+
.take(50)
86+
.collect::<String>();
87+
let common_merge_base = target.sha.to_string()[..7].to_string();
88+
println!("◉ {common_merge_base} (common base) {target_name} {message}");
7989
Ok(())
8090
}
8191

0 commit comments

Comments
 (0)