This script reads git diff and filters lines based on file category. This allows to see line changes for only source files or test or doccumentation.
If you add this script as git alias you'll be able to call it like git count source
$ ./git-diff-count-lines.sh count source
in 5 files: added: 13, removed: 142, total: 155, diff: -129
$ ./git-diff-count-lines.sh count source --nums
5 13 142 155 -129
$ git count source configs
in 11 files: added: 202, removed: 304, total: 506, diff: -102
$ git count list
source: 5 +13 -142 =155 :129
tests: 0 +0 -0 =0 :0
code: 5 +13 -142 =155 :129
configs: 6 +189 -162 =351 :27
assets: 0 +0 -0 =0 :0
docs: 0 +0 -0 =0 :0
Categories can be configured in count-lines.ini
, to include line write awk
regex for it, to exclude prepend !
to regex.
[category]
include = /(dir1|dir2)\/.*\.(ext1|ext2)/
exclude = !/^unwanted.file/