Browse Source

feat: count commit script tests and refactorings output

main
fdai7451 2 years ago
parent
commit
87158bc524
  1. 24
      count-commits.sh

24
count-commits.sh

@ -9,4 +9,26 @@ else
fi
echo "Commits per user:"
git shortlog -s -e --no-merges | sed 's/<//;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/<//;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
Loading…
Cancel
Save