ASCII 'punchcard' graph for git commits
#!/usr/bin/awk -f | |
# | |
# punchcard.awk - ASCII 'punchcard' graph for git log | |
# | |
# Written in September 2011 by Andreas Jaggi <andreas.jaggi@waterwave.ch> | |
# | |
# usage:$ git log | punchcard.awk | |
# +-------------------------------------------------------------------------------------------------+ | |
# Tue | . . o . . o O O 0 O | | |
# Wed | . . . . 0 O o | | |
# Thu | . . o O . . o o . . . | | |
# Fri | . . . . O o o | | |
# Sat | . . O . | | |
# Sun | . O o . o o o o o . . | | |
# Mon | . . . . . . . . o O O . . o 0 | | |
# +-------------------------------------------------------------------------------------------------+ | |
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
# | |
BEGIN { | |
days[1] = "Mon"; | |
days[2] = "Tue"; | |
days[3] = "Wed"; | |
days[4] = "Thu"; | |
days[5] = "Fri"; | |
days[6] = "Sat"; | |
days[7] = "Sun"; | |
for (d in days) { | |
for ( h = 0; h < 24; h++ ) { | |
data[days[d],h] = 0; | |
} | |
} | |
max = 0; | |
} | |
/Date:/{ | |
split($5,m,":"); | |
data[$2,(1*m[1])] = data[$2,(1*m[1])]+1; | |
if ( data[$2,(1*m[1])] > max ) { | |
max = data[$2,(1*m[1])]; | |
} | |
} | |
END { | |
printf(" +"); | |
for ( h = 0; h < 24; h++ ) { | |
printf("----", h); | |
} | |
printf("-+\n"); | |
for (d in days) { | |
printf("%s |", days[d]); | |
for ( h = 0; h < 24; h++ ) { | |
v = (4.0*data[days[d],h])/(max*1.0); | |
if ( v <= 0 ) { | |
printf(" "); | |
} | |
if ( (v > 0) && (v < 1) ) { | |
printf(" . "); | |
} | |
if ( (v >= 1) && (v < 2) ) { | |
printf(" o "); | |
} | |
if ( (v >= 2) && (v < 3) ) { | |
printf(" O "); | |
} | |
if ( (v >= 3) ) { | |
printf(" 0 "); | |
} | |
} | |
printf(" |\n") | |
} | |
printf(" +"); | |
for ( h = 0; h < 24; h++ ) { | |
printf("----", h); | |
} | |
printf("-+\n "); | |
for ( h = 0; h < 24; h++ ) { | |
printf("%- 3d ", h); | |
} | |
printf("\n"); | |
} |
The MIT License (MIT) | |
Copyright (c) 2011 Andreas Jaggi <andreas.jaggi@waterwave.ch> | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in | |
all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
THE SOFTWARE. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment