@@ -45,30 +45,28 @@ if [ -n "$MERGES_ARG" ] && [ -n "$SUMMARY_BY_LINE" ]; then
4545 exit 1
4646fi
4747
48-
48+ commit= " HEAD "
4949if [ -n " $SUMMARY_BY_LINE " ]; then
5050 paths=( " $@ " )
5151else
52- commit=" HEAD"
5352 [ $# -ne 0 ] && commit=$*
5453fi
5554project=${PWD##*/ }
5655
5756#
5857# get date for the given <commit>
5958#
60- date () {
59+ commit_date () {
6160 # the $1 can be empty
6261 # shellcheck disable=SC2086
63- git log $MERGES_ARG --pretty=' format: %ai' $1 | cut -d ' ' -f 2
62+ git log $MERGES_ARG --pretty=' format: %ai' " $1 " | cut -d ' ' -f 2
6463}
6564
6665#
6766# get active days for the given <commit>
6867#
6968active_days () {
70- # shellcheck disable=SC2086
71- date $1 | sort -r | uniq | awk '
69+ commit_date " $1 " | sort -r | uniq | awk '
7270 { sum += 1 }
7371 END { print sum }
7472 '
@@ -79,7 +77,7 @@ active_days() {
7977#
8078commit_count () {
8179 # shellcheck disable=SC2086
82- git log $MERGES_ARG --oneline $commit | wc -l | tr -d ' '
80+ git log $MERGES_ARG --oneline " $commit " | wc -l | tr -d ' '
8381}
8482
8583#
@@ -216,19 +214,17 @@ print_summary_by_line() {
216214print_summary () {
217215 if [ " $OUTPUT_STYLE " == " tabular" ]; then
218216 tabular_headers=" # Repo $SP Age $SP Last active $SP Active on $SP Commits $SP Uncommitted $SP Branch"
219- echo -e " $tabular_headers \n$project $SP $( repository_age) $SP $( last_active) $SP $( active_days $commit ) days $SP $( commit_count $commit ) $SP $( uncommitted_changes_count) $SP $( current_branch_name) " | column -t -s " $COLUMN_CMD_DELIMTER "
217+ echo -e " $tabular_headers \n$project $SP $( repository_age) $SP $( last_active) $SP $( active_days " $commit " ) days $SP $( commit_count " $commit " ) $SP $( uncommitted_changes_count) $SP $( current_branch_name) " | column -t -s " $COLUMN_CMD_DELIMTER "
220218 elif [ " $OUTPUT_STYLE " == " oneline" ]; then
221- echo " $project / age: $( repository_age) / last active: $( last_active) / active on $( active_days $commit ) days / commits: $( commit_count $commit ) / uncommitted: $( uncommitted_changes_count) / branch: $( current_branch_name) "
219+ echo " $project / age: $( repository_age) / last active: $( last_active) / active on $( active_days " $commit " ) days / commits: $( commit_count " $commit " ) / uncommitted: $( uncommitted_changes_count) / branch: $( current_branch_name) "
222220 else
223221 echo
224222 echo " project : $project "
225223 echo " repo age : $( repository_age) "
226224 echo " branch: : $( current_branch_name) "
227225 echo " last active : $( last_active) "
228- # shellcheck disable=SC2086
229- echo " active on : $( active_days $commit ) days"
230- # shellcheck disable=SC2086
231- echo " commits : $( commit_count $commit ) "
226+ echo " active on : $( active_days " $commit " ) days"
227+ echo " commits : $( commit_count " $commit " ) "
232228
233229 # The file count doesn't support passing a git ref so ignore it if a ref is given
234230 if [ " $commit " == " HEAD" ]; then
@@ -239,10 +235,10 @@ print_summary() {
239235 if [ -n " $DEDUP_BY_EMAIL " ]; then
240236 # the $commit can be empty
241237 # shellcheck disable=SC2086
242- git shortlog $MERGES_ARG -n -s -e $commit | dedup_by_email | format_authors
238+ git shortlog $MERGES_ARG -n -s -e " $commit " | dedup_by_email | format_authors
243239 else
244240 # shellcheck disable=SC2086
245- git shortlog $MERGES_ARG -n -s $commit | format_authors
241+ git shortlog $MERGES_ARG -n -s " $commit " | format_authors
246242 fi
247243 fi
248244}
0 commit comments