git-cal

Faire un calendrier d'activité git avec gnuplot - retour accueil

git clone git://bebou.netlib.re/git-cal
Log | Files | Refs | README |

countcommits.sh (881B)


      1 #! /bin/sh
      2 
      3 # PREP
      4 
      5 dateformat="%u %Y %b %d"
      6 LC_ALL=C oneyearago="$(date --date '-1 year')"
      7 
      8 l=$(mktemp); t=$(mktemp)
      9 
     10 folder="$1"; author="$2"
     11 [ -z "$folder"  ] && { echo "missing folder as first argument"        >&2 ;exit 1; }
     12 [ -z "$author"  ] && { echo "missing author regex as second argument" >&2 ;exit 1; }
     13 
     14 # GO
     15 
     16 gl() {
     17 	LC_ALL=C xargs -I{} \
     18 	         git -C {} log --after="$oneyearago" \
     19 			               --date=format:"$dateformat" \
     20 						   --author="$author" |
     21 		grep "^Date:" | cut -d' ' -f2- |
     22 		sort | uniq -c | sort -n
     23 }
     24 
     25 find "$folder" -maxdepth 5 -type d -name '.git' | gl > $t
     26 
     27 for d in $(seq 365 -1 0);do
     28 	day=$(LC_ALL=C date --date "today - $d days" +"$dateformat")
     29 	res=$(grep "$day" $t)
     30 	[ -n "$res" ] && echo "$res" || echo "0 $day"
     31 done > $l
     32 
     33 firstday=$(head -n1 $l | cut -f2 | cut -c1)
     34 
     35 seq 1 $(($firstday - 1)) | xargs printf "-1\n"
     36 cat $l
     37 
     38 rm $t $l