Skip to content

Commit

Permalink
Merge pull request #792 from spacewander/git-summary-cleanup
Browse files Browse the repository at this point in the history
clean up git-summary
  • Loading branch information
spacewander authored Nov 1, 2019
2 parents a14547e + f788c78 commit 2883b67
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions bin/git-summary
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -44,6 +46,7 @@ date() {
#

active_days() {
# shellcheck disable=SC2086
date $1 | sort -r | uniq | awk '
{ sum += 1 }
END { print sum }
Expand Down Expand Up @@ -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';
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2883b67

Please sign in to comment.