Skip to content

Instantly share code, notes, and snippets.

@s1037989
Last active April 21, 2022 01:27
Show Gist options
  • Save s1037989/1f881ddacfcdb3f7ff7f8ba6365acb31 to your computer and use it in GitHub Desktop.
Save s1037989/1f881ddacfcdb3f7ff7f8ba6365acb31 to your computer and use it in GitHub Desktop.
sloc
$ function sloc { local author="$1" from="$2" to="$3" path="$4"; while read hash; do git diff-tree --numstat --no-commit-id $hash | grep -P '^\d+\s+\d+\s+'$path; done < <(git log --author='^('$author').*$' --perl-regexp --format='%H' $from..$to) | perl -pE 'END { say "$a\t$b" } @_=split/\s+/;$a+=$_[0]; $b+=$_[1]'; }
$ sloc Sebastian 18f95d36c c87e5244d4 lib
1 1 lib/Mojolicious.pm
1 1 lib/Mojo/Headers.pm
8 4 lib/Mojo/Asset/Memory.pm
1 1 lib/Mojolicious.pm
2 2 lib/Mojolicious.pm
1 1 lib/Mojolicious/resources/templates/mojo/debug.html.ep
1 1 lib/Mojolicious/Guides/Rendering.pod
1 1 lib/Mojolicious/Guides/Tutorial.pod
16 12
$ sloc Sebastian 18f95d36c c87e5244d4 t
4 0 t/mojo/asset.t
9 0 t/mojo/asset.t
13 0
$ git show -s --format='%ae%x09%an' 64354fac
[email protected] Sebastian Riedel
$ git diff-tree --numstat --no-commit-id 64354fac
2 1 Changes
1 1 lib/Mojo/Headers.pm
$ git diff-tree --shortstat --no-commit-id 64354fac
2 files changed, 3 insertions(+), 2 deletions(-)
$ sloc Sebastian 64354fac0 64354fac0 lib
$ sloc Sebastian 64354fac0^ 64354fac0 lib
1 1 lib/Mojo/Headers.pm
1 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment