diff --git a/README.md b/README.md index bf979f32e..bd6d441df 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ If you wrote one of these scripts and want it removed from this collection, plea | `git-improved-merge` | Mislav Marohnić's [dotfiles](https://github.com/mislav/dotfiles) | Sophisticated git merge with integrated CI check and automatic cleanup. | | `git-incoming-commits` | Ryan Tomayko's [dotfiles](https://github.com/rtomayko/dotfiles) | Adds a remote for the current repository for the given github username. | | `git-incoming` | Michael Markert's [dotfiles](https://github.com/cofi/dotfiles) | Show commits in the tracking branch that are not in the local branch. | +| `git-lines` | Neil Killeen | Gives you a list of author names with the number of lines last updated by that user in files in the current directory tree with the extension specified. | | `git-ls-object-refs` | Ryan Tomayko's [dotfiles](https://github.com/rtomayko/dotfiles) | Find references to an object with SHA1 in refs, commits, and trees. All of them. | | `git-maildiff` | Sanjeev Kumar's [blogpost](http://www.devilsan.com/blog/my-first-git-command-git-ipush-using-python) | A simple git command to email diff in color to reviewer/ co-worker. | | `git-maxpack` | John Wiegley's [git-scripts](https://github.com/jwiegley/git-scripts) | Compress a repo's pack files as much as possible. | diff --git a/bin/git-lines b/bin/git-lines new file mode 100755 index 000000000..fb5f8e2f8 --- /dev/null +++ b/bin/git-lines @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# +# Gives you a list of names with the number of lines last updated by that +# user in files with the extension specified +# +# Copyright 2019, Neil Killeen +# +# Requires GNU sed + +set -o pipefail + +temp_ifs=$IFS; +temp_lc_all=$LC_ALL +IFS="|" +LC_ALL="C" +args="$*" + +git ls-tree -r HEAD | \ + gsed -re 's/^.{53}//' | \ + while read filename; do file "$filename"; done | \ + grep -E ".*\.(${args})" | \ + gsed -r -e 's/: .*//' | \ + while read filename; do git blame -w "$filename"; done | \ + gsed -r -e 's/.*\((.*)[0-9]{4}-[0-9]{2}-[0-9]{2} .*/\1/' -e 's/ +$//' | \ + sort -gif | uniq -c + +IFS=${temp_ifs} +LC_ALL=${temp_lc_all}