Created
July 6, 2018 14:25
-
-
Save jakub-bochenski/dde1e39068e8edc62e72ddbd1626a8be to your computer and use it in GitHub Desktop.
Output changed file paths and lines based on git diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
path='^\+\+\+ .\/(.*)' | |
hunk='^@@ -[0-9]+(,[0-9]+|) \+([0-9]+)(,([0-9]+|)|) @@' | |
while read -r line | |
do | |
if [[ $line =~ $path ]] | |
then | |
echo "${BASH_REMATCH[1]}:" | |
fi | |
if [[ $line =~ $hunk ]] | |
then | |
echo " - start: ${BASH_REMATCH[2]}" | |
echo " count: ${BASH_REMATCH[4]:-1}" | |
fi | |
done < <(git diff --unified=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment