grit equivalent of git diff

96 Views Asked by At

I am trying to find all the lines of code within the current git diff that have been deleted (in the unstaged changes) using the ruby gem grit, i.e. I want to see all the unstaged changes involving deletions. This would be the equivalent of doing git diff -U0 | grep ^-[^-] in the shell.

So far I have only been able to figure out how to get the diffs between two commits, or get the names of the files that have been changed.

1

There are 1 best solutions below

2
Малъ Скрылевъ On BEST ANSWER

Try as follows:

diff = @repo.git.diff({:U0 => true}).split( "\n" ).grep( /^-[^-]/ ).join( "\n" )