Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <nkilleen@castlighthealth.com> | 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. |
Expand Down
28 changes: 28 additions & 0 deletions bin/git-lines
Original file line number Diff line number Diff line change
@@ -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 <nkilleen@castlighthealth.com>
#
# 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}