get_git_diff

Function get_git_diff 

Source
pub fn get_git_diff() -> String
Expand description

Get git diff from the current working directory.

Tries in order:

  1. Unstaged changes (git diff)
  2. Staged changes (git diff --cached)
  3. Last commit diff (git diff HEAD~1)

Returns empty string if not in a git repository or no changes found.

ยงExample

use ratatui_toolkit::code_diff::helpers::get_git_diff;

let diff = get_git_diff();
if !diff.is_empty() {
    println!("Found changes:\n{}", diff);
}