diff --git a/bin/git-summary b/bin/git-summary index cc77beb..58f1788 100755 --- a/bin/git-summary +++ b/bin/git-summary @@ -36,6 +36,8 @@ project=${PWD##*/} # date() { + # the $1 can be empty + # shellcheck disable=SC2086 git log --pretty='format: %ai' $1 | cut -d ' ' -f 2 } @@ -44,6 +46,7 @@ date() { # active_days() { + # shellcheck disable=SC2086 date $1 | sort -r | uniq | awk ' { sum += 1 } END { print sum } @@ -137,7 +140,7 @@ repository_age() { # list the last modified author for each line # single_file() { - while read data + while read -r data do if [[ $(file "$data") = *text* ]]; then git blame --line-porcelain "$data" 2>/dev/null | grep "^author\ " | LC_ALL=C sed -n 's/^author //p'; @@ -159,17 +162,6 @@ line_count() { lines | wc -l } -result() { - lines | sort | uniq -c | sort -rn | awk ' - { args[NR] = $0; sum += $0 } - END { - for (i = 1; i <= NR; ++i) { - printf " %s, %2.1f%%\n", args[i], 100 * args[i] / sum - } - } - ' | column -t -s, -} - # summary echo @@ -181,9 +173,11 @@ if [ -n "$SUMMARY_BY_LINE" ]; then lines | sort | uniq -c | sort -rn | format_authors else + # shellcheck disable=SC2046 echo " repo age :" $(repository_age) - echo " active :" $(active_days) days - echo " commits :" $(commit_count) + # shellcheck disable=SC2086 + echo " active :" "$(active_days $commit)" days + echo " commits :" "$(commit_count)" if test "$commit" = ""; then echo " files :" "$(file_count)" fi