You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.3 KiB

  1. #!/bin/bash
  2. total_commits=$(git shortlog -s -n --no-merges | awk '{ sum += $1; } END { print sum; }' "$@")
  3. if [[ $total_commits -gt 200 ]]; then
  4. echo "Total commits: $total_commits (minimum required commits reached)"
  5. else
  6. echo "Total commits: $total_commits ($(expr 200 - $total_commits) commits left to reach minimum required commits)"
  7. fi
  8. echo "Commits per user:"
  9. for user in $(git shortlog -s | awk '{ print $2 }'); do
  10. email=$(git shortlog -s -e --author="$user" | sed 's/<//;s/>//' | awk '{ print $3 }')
  11. total_commits=$(git shortlog -s --perl-regexp --author="$user" | awk '{ print $1 }')
  12. test_commits=$(git shortlog -s --perl-regexp --author="$user" --grep='^test:' | awk '{ print $1 }')
  13. refactor_commits=$(git shortlog -s --perl-regexp --author="$user" --grep='^refactoring:' | awk '{ print $1 }')
  14. if [[ $test_commits -eq 0 ]]; then
  15. test_commits=0
  16. test_percentage=0
  17. else
  18. test_percentage=$(echo "$test_commits/$total_commits*100" | bc -l | xargs printf "%.2f")
  19. fi
  20. if [[ $refactor_commits -eq 0 ]]; then
  21. refactor_commits=0
  22. refactor_percentage=0
  23. else
  24. refactor_percentage=$(echo "$refactor_commits/$total_commits*100" | bc -l | xargs printf "%.2f")
  25. fi
  26. echo -e "\t$user ($email): Total $total_commits, Tests: $test_commits ($test_percentage%), Refactorings: $refactor_commits ($refactor_percentage%)"
  27. done