From 3bff96acab6437fcc22fd354327997da2516e5dd Mon Sep 17 00:00:00 2001 From: Triston Armstrong Date: Sun, 12 Jan 2025 13:10:23 -0500 Subject: [PATCH] "feat(grabber): Update GitGrabber to ignore whitespace and blank lines in diff output" --- src/git_grabber.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/git_grabber.rs b/src/git_grabber.rs index 14f61e9..fd24415 100644 --- a/src/git_grabber.rs +++ b/src/git_grabber.rs @@ -20,13 +20,24 @@ impl GitGrabber { .expect("Failed to get branch"); let b = from_utf8(&branch.stdout).unwrap(); - String::from(b) + String::from(b.strip_suffix("\n").unwrap()) } pub fn get_diff() -> String { // just to print - let staged_files_output = Command::new("git") - .args(["diff", "--staged"]) + let output = Command::new("git") + .args([ + "diff", + "--staged", + "--ignore-all-space", + "--ignore-blank-lines", + "--ignore-cr-at-eol", + "--minimal", + "--no-prefix", + "--no-renames", + "--word-diff", + "--inter-hunk-context=0", + ]) .output() .expect("Failed to get diff");