Skip to content

Instantly share code, notes, and snippets.

@allanpedroni
Created March 4, 2020 16:26
Show Gist options
  • Save allanpedroni/fd2b7bee42aa5e446987bf15f21ead41 to your computer and use it in GitHub Desktop.
Save allanpedroni/fd2b7bee42aa5e446987bf15f21ead41 to your computer and use it in GitHub Desktop.
get length of lines changed between local and master. there is some conditions with exclusions.
#!/bin/bash
diff_shortstat=$(git diff --shortstat master -- ":*.cs" ":(exclude)*Tests/*")
insertions=$(echo $diff_shortstat | grep -Po '\K[0-9]+(?= insertions?)' || echo "0")
deletions=$(echo $diff_shortstat | grep -Po '\K[0-9]+(?= deletions?)' || echo "0")
total_lines=$(( insertions + deletions ))
ignored_lines=$(git diff master -- ":*.cs" ":(exclude)*Tests/*" | egrep -c "^[+-]\s*(\/\/.*|)$")
total=$(( $total_lines - $ignored_lines ))
echo "$total linha(s) adiciona(s) e removida(s)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment