1use std::process::Command;
2
3pub fn run(reference: String) {
4 let output = Command::new("git")
5 .args([
6 "log",
7 &format_git_log_range(&reference),
8 "--pretty=format:- %h %s",
9 ])
10 .output()
11 .expect("Failed to run git log");
12
13 if !output.status.success() {
14 eprintln!("❌ Failed to retrieve commits since '{reference}'");
15 return;
16 }
17
18 let log = String::from_utf8_lossy(&output.stdout);
19 if is_log_empty(&log) {
20 println!("✅ No new commits since {reference}");
21 } else {
22 println!("🔍 Commits since {reference}:");
23 println!("{log}");
24 }
25}
26
27pub fn format_git_log_range(reference: &str) -> String {
29 format!("{reference}..HEAD")
30}
31
32pub fn is_log_empty(log_output: &str) -> bool {
34 log_output.trim().is_empty()
35}