pub fn get_git_diff() -> StringExpand description
Get git diff from the current working directory.
Tries in order:
- Unstaged changes (
git diff) - Staged changes (
git diff --cached) - 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);
}