git_editor/rewrite/
report.rs1use crate::rewrite::engine::Outcome;
4use colored::Colorize;
5
6fn short(oid: git2::Oid) -> String {
7 oid.to_string()[..8].to_string()
8}
9
10pub fn print_outcome(outcome: &Outcome) {
11 if crate::output::json_mode() {
12 crate::output::emit(&crate::output::outcome_json(outcome));
13 return;
14 }
15 if !outcome.changed() {
16 crate::say!(
17 "{}",
18 "No commits needed rewriting; branch unchanged.".yellow()
19 );
20 return;
21 }
22 crate::say!(
23 "{} '{}': {} -> {}",
24 "Rewritten branch".green(),
25 outcome.branch.cyan(),
26 short(outcome.old_head).red(),
27 short(outcome.new_head).green()
28 );
29 crate::say!(
30 " {} commit(s) recreated, {} reused unchanged",
31 outcome.rewritten.len(),
32 outcome.reused
33 );
34 if outcome.signatures_dropped > 0 {
35 crate::say!(
36 " {} {} recreated commit(s) were signed; their signatures were removed (re-sign if needed)",
37 "Note:".yellow(),
38 outcome.signatures_dropped
39 );
40 }
41 if let Some(backup) = &outcome.backup_ref {
42 crate::say!(
43 " Previous tip saved as {} (undo: git reset --keep {})",
44 backup.cyan(),
45 backup
46 );
47 }
48 if !outcome.stale_refs.is_empty() {
49 crate::say!(
50 " {} these refs still point to the old history: {}",
51 "Warning:".yellow().bold(),
52 outcome.stale_refs.join(", ")
53 );
54 }
55}