@@ -45,30 +45,28 @@ if [ -n "$MERGES_ARG" ] && [ -n "$SUMMARY_BY_LINE" ]; then
45
45
exit 1
46
46
fi
47
47
48
-
48
+ commit= " HEAD "
49
49
if [ -n " $SUMMARY_BY_LINE " ]; then
50
50
paths=( " $@ " )
51
51
else
52
- commit=" HEAD"
53
52
[ $# -ne 0 ] && commit=$*
54
53
fi
55
54
project=${PWD##*/ }
56
55
57
56
#
58
57
# get date for the given <commit>
59
58
#
60
- date () {
59
+ commit_date () {
61
60
# the $1 can be empty
62
61
# 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
64
63
}
65
64
66
65
#
67
66
# get active days for the given <commit>
68
67
#
69
68
active_days () {
70
- # shellcheck disable=SC2086
71
- date $1 | sort -r | uniq | awk '
69
+ commit_date " $1 " | sort -r | uniq | awk '
72
70
{ sum += 1 }
73
71
END { print sum }
74
72
'
@@ -79,7 +77,7 @@ active_days() {
79
77
#
80
78
commit_count () {
81
79
# 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 ' '
83
81
}
84
82
85
83
#
@@ -216,19 +214,17 @@ print_summary_by_line() {
216
214
print_summary () {
217
215
if [ " $OUTPUT_STYLE " == " tabular" ]; then
218
216
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 "
220
218
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) "
222
220
else
223
221
echo
224
222
echo " project : $project "
225
223
echo " repo age : $( repository_age) "
226
224
echo " branch: : $( current_branch_name) "
227
225
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 " ) "
232
228
233
229
# The file count doesn't support passing a git ref so ignore it if a ref is given
234
230
if [ " $commit " == " HEAD" ]; then
@@ -239,10 +235,10 @@ print_summary() {
239
235
if [ -n " $DEDUP_BY_EMAIL " ]; then
240
236
# the $commit can be empty
241
237
# 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
243
239
else
244
240
# shellcheck disable=SC2086
245
- git shortlog $MERGES_ARG -n -s $commit | format_authors
241
+ git shortlog $MERGES_ARG -n -s " $commit " | format_authors
246
242
fi
247
243
fi
248
244
}
0 commit comments