Skip to content

Commit 3923e0b

Browse files
committed
ensure diff stats appear for remote branches
1 parent eff4a40 commit 3923e0b

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

src/main.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -570,11 +570,10 @@ fn recur_tree(
570570
let branch_color = dim.apply(colors::GRAY);
571571
let muted_color = dim.apply(colors::MUTED);
572572
println!(
573-
"{} {}",
573+
"{}",
574574
branch
575575
.name
576-
.truecolor(branch_color.0, branch_color.1, branch_color.2),
577-
"(remote)".truecolor(muted_color.0, muted_color.1, muted_color.2)
576+
.truecolor(branch_color.0, branch_color.1, branch_color.2)
578577
);
579578

580579
// Recurse into children
@@ -615,7 +614,7 @@ fn recur_tree(
615614
let branch_color = if branch_status.is_descendent {
616615
dim.apply(colors::GREEN)
617616
} else {
618-
dim.apply(colors::RED)
617+
dim.apply(colors::YELLOW)
619618
};
620619
let branch_name_colored = if is_current_branch {
621620
branch
@@ -628,30 +627,26 @@ fn recur_tree(
628627
.truecolor(branch_color.0, branch_color.1, branch_color.2)
629628
};
630629

631-
// Remote-only indicator
632-
let remote_indicator = if is_remote_only {
633-
let muted = dim.apply(colors::MUTED);
634-
format!(" {}", "(remote)".truecolor(muted.0, muted.1, muted.2))
635-
} else {
636-
String::new()
637-
};
630+
// Get diff stats from LKG ancestor (or parent branch) to current branch
631+
let diff_stats = {
632+
// Try lkg_parent first, fall back to resolved parent branch
633+
let base_ref = branch
634+
.lkg_parent
635+
.as_deref()
636+
.unwrap_or(&branch_status.parent_branch);
638637

639-
// Get diff stats from LKG ancestor to current branch
640-
let diff_stats = if let Some(lkg_parent) = branch.lkg_parent.as_ref() {
641-
match git_repo.diff_stats(lkg_parent, &branch_status.sha) {
638+
match git_repo.diff_stats(base_ref, &branch_status.sha) {
642639
Ok((adds, dels)) => {
643640
let green = dim.apply(colors::GREEN);
644641
let red = dim.apply(colors::RED);
645642
format!(
646-
" {} {}",
643+
" [{} {}]",
647644
format!("+{}", adds).truecolor(green.0, green.1, green.2),
648645
format!("-{}", dels).truecolor(red.0, red.1, red.2)
649646
)
650647
}
651-
Err(_) => String::new(), // Silently skip on error
648+
Err(_) => String::new(),
652649
}
653-
} else {
654-
String::new() // No LKG = no stats (e.g., trunk root)
655650
};
656651

657652
// Get local changes summary for current branch only
@@ -700,9 +695,8 @@ fn recur_tree(
700695
let upstream_color = dim.apply(colors::UPSTREAM);
701696

702697
println!(
703-
"{}{}{}{} ({}) {}{}{}{}",
698+
"{}{}{} ({}) {}{}{}{}",
704699
branch_name_colored,
705-
remote_indicator,
706700
diff_stats,
707701
local_status,
708702
branch_status.sha[..8].truecolor(gold.0, gold.1, gold.2),
@@ -841,8 +835,8 @@ fn recur_tree(
841835
String::new()
842836
};
843837
println!(
844-
"{}{}{}{}{}",
845-
branch_name_colored, remote_indicator, diff_stats, local_status, pr_info
838+
"{}{}{}{}",
839+
branch_name_colored, diff_stats, local_status, pr_info
846840
);
847841
}
848842

0 commit comments

Comments
 (0)