mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
add git-line-summary
This commit is contained in:
parent
84855b803d
commit
0386eb5bbe
58
bin/git-line-summary
Executable file
58
bin/git-line-summary
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
#!/bin/bash
|
||||
|
||||
project=${PWD##*/}
|
||||
|
||||
#
|
||||
# list the last modified author for each line
|
||||
#
|
||||
function single_file {
|
||||
while read data
|
||||
do
|
||||
git blame --line-porcelain $data | sed -n 's/^author //p'
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# list the author for all file
|
||||
#
|
||||
function lines {
|
||||
git ls-files | single_file
|
||||
}
|
||||
|
||||
#
|
||||
# count the line count
|
||||
#
|
||||
function count {
|
||||
lines | wc -l
|
||||
}
|
||||
|
||||
#
|
||||
# sort by author modified lines
|
||||
#
|
||||
function authors {
|
||||
lines | sort | uniq -c | sort -rn
|
||||
}
|
||||
|
||||
#
|
||||
# list as percentage for author modified lines
|
||||
#
|
||||
function result {
|
||||
authors | awk '
|
||||
{ args[NR] = $0; sum += $0 }
|
||||
END {
|
||||
for (i = 1; i <= NR; ++i) {
|
||||
printf "%-30s %2.1f%%\n", args[i], 100 * args[i] / sum
|
||||
}
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
# summary
|
||||
|
||||
echo
|
||||
echo " project : $project"
|
||||
echo " lines :" $(count)
|
||||
echo " authors : "
|
||||
result
|
||||
echo
|
||||
|
||||
Loading…
Reference in a new issue