From 0172f7e28d6974290bf7197836c03120ba4485c4 Mon Sep 17 00:00:00 2001 From: Newell Zhu Date: Sat, 9 May 2015 17:07:29 +0800 Subject: [PATCH] Fix Fatal for git-line-summary 1. Fix print format with special characters 2. Fix Fatal when exist special characters in git blame output 3. Fix raise error when exist not committed new files --- bin/git-line-summary | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/git-line-summary b/bin/git-line-summary index 43010dc88..64188c6d6 100755 --- a/bin/git-line-summary +++ b/bin/git-line-summary @@ -3,13 +3,13 @@ project=${PWD##*/} # -# list the last modified author for each line +# list the last modified author for each line # function single_file { while read data do - if [[ $(file $data) = *text* ]]; then # - git blame --line-porcelain $data | sed -n 's/^author //p'; + if [[ $(file $data) = *text* ]]; then # + git blame --line-porcelain $data 2>/dev/null | grep "author\ " | sed -n 's/^author //p'; fi done } @@ -42,19 +42,19 @@ function result { authors | awk ' { args[NR] = $0; sum += $0 } END { - printf " %-9s: %i\n", "lines", sum - printf " %-9s: \n", "authors" for (i = 1; i <= NR; ++i) { - printf " %-30s %2.1f%%\n", args[i], 100 * args[i] / sum + printf " %s, %2.1f%%\n", args[i], 100 * args[i] / sum } } - ' + ' | column -t -s, } # summary echo echo " project : $project" +echo " lines :" $(count) +echo " authors :" result echo