Last active
February 14, 2020 08:29
-
-
Save arzzen/293d165598a4a8c3a722da49ca241c3b to your computer and use it in GitHub Desktop.
draft_fnc_commitsByWeekday
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function commitsByWeekday() { | |
optionPicked "Git commits by weekday:" | |
echo -e "\tday\tsum" | |
local counter=1 | |
for i in Mon Tue Wed Thu Fri Sat Sun | |
do | |
echo -en "\t$counter\t$i\t" | |
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \ | |
$_since $_until | grep "$i " | wc -l | |
counter=$((counter+1)) | |
done | awk '{ | |
} | |
NR == FNR { | |
count[$1" "$2] = $3; | |
total += $3; | |
next | |
} | |
END{ | |
for (day in count) { | |
s="|"; | |
if (total > 0) { | |
percent = ((count[day] / total) * 100) / 1.25; | |
for (i = 1; i <= percent; ++i) { | |
s=s"█" | |
} | |
printf("\t%s\t%s\t%-0s\t%s\n", substr(day,0,1), substr(day,3,5), count[day], s); | |
} | |
} | |
}' | sort -k 1 -n | awk '{$1=""}1' | awk '{$1=$1}1' | awk '{printf("\t%s\t%s\t%s\n", $1, $2, $3)}' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code snippet appears to handle what Issue #91 mentions. Tested successfully on RHEL 7.6, WSL (Ubuntu 16.04), and macOS 10.14.
The only change I would make would be to make
counter
local i.e.local counter=1
so that it is not within the global scope.Nice work :)