mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Merge pull request #792 from spacewander/git-summary-cleanup
clean up git-summary
This commit is contained in:
commit
2883b67644
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue