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.

35 lines
1.3 KiB

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