giff 0.1.0

Visualizes the differences between the current HEAD and a specified branch in a git repository using a formatted table output in your terminal. The differences are displayed with color-coded additions and deletions for better readability.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::error::Error;
use std::process::Command;

pub fn get_diff_output(branch: &str) -> Result<String, Box<dyn Error>> {
    let output = Command::new("git")
        .args(["diff", &format!("{}..HEAD", branch)])
        .output()?;

    if !output.status.success() {
        eprintln!("Failed to execute git diff command");
        std::process::exit(1);
    }

    Ok(String::from_utf8_lossy(&output.stdout).to_string())
}