From 87158bc524480fb03b62a5215548d70026dca455 Mon Sep 17 00:00:00 2001 From: fdai7451 Date: Tue, 17 Jan 2023 08:55:05 +0100 Subject: [PATCH] feat: count commit script tests and refactorings output --- count-commits.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/count-commits.sh b/count-commits.sh index aa57575..4919117 100755 --- a/count-commits.sh +++ b/count-commits.sh @@ -9,4 +9,26 @@ else fi echo "Commits per user:" -git shortlog -s -e --no-merges | sed 's///' | awk '{ printf "\t%s (%s): %s\n", $2, $3, $1 }' +for user in $(git shortlog -s | awk '{ print $2 }'); do + email=$(git shortlog -s -e --author="$user" | sed 's///' | awk '{ print $3 }') + total_commits=$(git shortlog -s --perl-regexp --author="$user" | awk '{ print $1 }') + test_commits=$(git shortlog -s --perl-regexp --author="$user" --grep='^test:' | awk '{ print $1 }') + refactor_commits=$(git shortlog -s --perl-regexp --author="$user" --grep='^refactoring:' | awk '{ print $1 }') + + if [[ $test_commits -eq 0 ]]; then + test_commits=0 + test_percentage=0 + else + test_percentage=$(echo "$test_commits/$total_commits*100" | bc -l | xargs printf "%.2f") + fi + + if [[ $refactor_commits -eq 0 ]]; then + refactor_commits=0 + refactor_percentage=0 + else + refactor_percentage=$(echo "$refactor_commits/$total_commits*100" | bc -l | xargs printf "%.2f") + fi + + echo -e "\t$user ($email): Total $total_commits, Tests: $test_commits ($test_percentage%), Refactorings: $refactor_commits ($refactor_percentage%)" +done +