Skip to content

Instantly share code, notes, and snippets.

@arzzen
Last active February 14, 2020 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arzzen/293d165598a4a8c3a722da49ca241c3b to your computer and use it in GitHub Desktop.
Save arzzen/293d165598a4a8c3a722da49ca241c3b to your computer and use it in GitHub Desktop.
draft_fnc_commitsByWeekday
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)}'
}
@tomice
Copy link

tomice commented Feb 14, 2020

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment