From 3077af47cdeb890f09ad5c13bbf75ed103d453e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Oct 2022 03:34:24 +0200 Subject: [PATCH] Git: Add a tool to count nb of lines of code between tag per users. --- dev/tools/github_authors_and_commits_peryear.sh | 5 ++++- dev/tools/github_commits_perversion.sh | 8 ++++++-- dev/tools/github_lines_perusers.sh | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100755 dev/tools/github_lines_perusers.sh diff --git a/dev/tools/github_authors_and_commits_peryear.sh b/dev/tools/github_authors_and_commits_peryear.sh index 7184d6c44ae..bdba2a2a6ed 100755 --- a/dev/tools/github_authors_and_commits_peryear.sh +++ b/dev/tools/github_authors_and_commits_peryear.sh @@ -1,5 +1,8 @@ #!/bin/sh - +# +# Count number of different contributors and number of commits for a given year. +# + if [ "x$1" = "x" ]; then echo "Usage: $0 YEAR" exit diff --git a/dev/tools/github_commits_perversion.sh b/dev/tools/github_commits_perversion.sh index bf76e68bc43..2f3020ff721 100755 --- a/dev/tools/github_commits_perversion.sh +++ b/dev/tools/github_commits_perversion.sh @@ -1,6 +1,10 @@ #/bin/bash -Releases=("3.8" "3.9" "4.0" "5.0" "6.0" " 7.0" "develop") -Dates=("2013-01-01", "2014-01-01", "2015-01-01", "2016-07-01", "2017-02-01", "2017-07-01", "2018-02-01", "2050-01-01") +# +# Count number of commits per user and per versions (using date for version detection) +# + +Releases=("16.0" "develop") +Dates=("2022-01-01" "2022-08-31" "2050-01-01") let "counter = 1" for i in "${Releases[@]}" diff --git a/dev/tools/github_lines_perusers.sh b/dev/tools/github_lines_perusers.sh new file mode 100755 index 00000000000..5e65ddc6bf9 --- /dev/null +++ b/dev/tools/github_lines_perusers.sh @@ -0,0 +1,16 @@ +#/bin/bash +# +# Count number of lines modified per user for a given branch +# + +if [ "x$2" = "x" ]; then + echo "Usage: $0 tagnamestart|START tagnameend|HEAD" + exit +fi + + +echo "git log $1..$2 --shortstat | grep ... | perl ... > /tmp/github_lines_perusers.tmp" +git log $1..$2 --shortstat | grep -e 'Author:' -e 'Date:' -e ' changed' -e ' insertion' -e ' deletion' | perl -n -e '/^(.*)$/; $line = $1; if ($line =~ /(changed|insertion|deletion)/) { $line =~ s/[^0-9\s]//g; my @arr=split /\s+/, $line; $tot=0; for (1..@arr) { $tot += $arr[$_]; }; print $tot."\n"; } else { print $line."\n"; };' > /tmp/github_lines_perusers.tmp + +cat /tmp/github_lines_perusers.tmp | awk 'BEGIN { FS="\n"; print "user and nb of lines"; lastuser=""; } { if ($1 ~ /Author:/) { lastuser=$1 }; if ($1 ~ /^[0-9]+$/) { aaa[lastuser]=$1; } } END { for (var in aaa) print var," ",aaa[var]; } ' +