Skip to content

Commit 0523a5a

Browse files
authored
Merge pull request #99 from unixorn/add-git-lines
Add Neil's git-lines script
2 parents 0f2b98a + 22a7cbb commit 0523a5a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ If you wrote one of these scripts and want it removed from this collection, plea
7272
| `git-improved-merge` | Mislav Marohnić's [dotfiles](https://github.com/mislav/dotfiles) | Sophisticated git merge with integrated CI check and automatic cleanup. |
7373
| `git-incoming-commits` | Ryan Tomayko's [dotfiles](https://github.com/rtomayko/dotfiles) | Adds a remote for the current repository for the given github username. |
7474
| `git-incoming` | Michael Markert's [dotfiles](https://github.com/cofi/dotfiles) | Show commits in the tracking branch that are not in the local branch. |
75+
| `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. |
7576
| `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. |
7677
| `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. |
7778
| `git-maxpack` | John Wiegley's [git-scripts](https://github.com/jwiegley/git-scripts) | Compress a repo's pack files as much as possible. |

bin/git-lines

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Gives you a list of names with the number of lines last updated by that
4+
# user in files with the extension specified
5+
#
6+
# Copyright 2019, Neil Killeen <nkilleen@castlighthealth.com>
7+
#
8+
# Requires GNU sed
9+
10+
set -o pipefail
11+
12+
temp_ifs=$IFS;
13+
temp_lc_all=$LC_ALL
14+
IFS="|"
15+
LC_ALL="C"
16+
args="$*"
17+
18+
git ls-tree -r HEAD | \
19+
gsed -re 's/^.{53}//' | \
20+
while read filename; do file "$filename"; done | \
21+
grep -E ".*\.(${args})" | \
22+
gsed -r -e 's/: .*//' | \
23+
while read filename; do git blame -w "$filename"; done | \
24+
gsed -r -e 's/.*\((.*)[0-9]{4}-[0-9]{2}-[0-9]{2} .*/\1/' -e 's/ +$//' | \
25+
sort -gif | uniq -c
26+
27+
IFS=${temp_ifs}
28+
LC_ALL=${temp_lc_all}

0 commit comments

Comments
 (0)