git-cal

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

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

commit 71837eb4bde095a25a1cc44978b1ea978b21b4c8
parent c83912738eb9147a640b605780d1544018f5bde5
Auterice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Wed, 23 Oct 2024 15:45:23 +0200

Simplification

Le .sh est plus simple
Le .gp gère maintenant dynaimquement la teinte de la palette

Diffstat:
Mcountcommits.sh | 32+++++++++++++++++++++-----------
Mgraph.gp | 14+++++++-------
2 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/countcommits.sh b/countcommits.sh @@ -1,25 +1,35 @@ #! /bin/sh -t=$(mktemp) -l=$(mktemp) +# PREP + dateformat="%u %Y %b %d" -for dep in $(find "${1:?folder ?}/"* -maxdepth 0 -type d );do - cd $dep - LC_ALL=C git log --date=format:"$dateformat" --author="${2:?author name ?}" | grep Date: -done | - cut -d ' ' -f2- | - sort | uniq -c | sort -n | - sed -E 's, *([0-9]+) *,\1 ,' > $t +LC_ALL=C oneyearago="$(date --date '-1 year')" + +l=$(mktemp); t=$(mktemp) + +folder="$1"; author="$2" +[ -z "$folder" ] && { echo "missing folder as first argument" >&2 ;exit 1; } +[ -z "$author" ] && { echo "missing author regex as second argument" >&2 ;exit 1; } + +# GO + +gl() { + LC_ALL=C xargs -I{} git -C {} log --after="$oneyearago" --date=format:"$dateformat" --author="$author" | + grep "^Date:" | cut -d' ' -f2- | + sort | uniq -c | sort -n +} + +find "$folder"/* -maxdepth 0 -type d | gl > $t for d in $(seq 365 -1 0);do day=$(LC_ALL=C date --date "today - $d days" +"$dateformat") res=$(grep "$day" $t) - [ -n "$res" ] && echo "$res" || echo "0 $day" + [ -n "$res" ] && echo "$res" || echo "0 $day" done > $l firstday=$(head -n1 $l | cut -f2 | cut -c1) -seq 1 $(($firstday - 1)) | xargs printf "0 %s\n" +seq 1 $(($firstday - 1)) | xargs printf "-1\n" cat $l rm $t $l diff --git a/graph.gp b/graph.gp @@ -3,7 +3,6 @@ set term pngcairo width=2000 set term pngcairo size width,(width/(52/7)) -set datafile separator "\t" set tmargin 1; set lmargin 6.5 @@ -13,15 +12,16 @@ y(nl) = int(nl*-1)%7 set border 0 unset key unset tics -unset colorbox -set palette defined ( 0 "#EEEEEE", 1 "light-blue", 20 "blue", 50 "dark-blue" ) +stats 'nbofcommits.tsv' u 1 nooutput +set cbrange [0:STATS_max] +set palette defined ( 0 "#EEEEEE", 1 "light-blue", STATS_max/2 "blue", STATS_max "dark-blue" ) set label "Mon" at -1.5, 0 set label "Thu" at -1.5,-3 set label "Sun" at -1.5,-6 -plot 'nbofcommits.tsv' u (words(strcol(2))>1 ? x($0):NaN):(y($0)):1 \ - with points \ - pointtype 5 pointsize 5 linecolor palette, \ -'' u (x($0)):(word(strcol(2),4) eq "01" ? 1.3:NaN):(word(strcol(2),3)) w labels +plot 'nbofcommits.tsv' u ($1==-1 ? NaN:x($0)):(y($0)):1 \ + w p \ + pt 5 ps 5 lc palette, \ + '' u (x($0)):($5==1 ? 1.3:NaN):(strcol(4)) w labels