genExp.sh 843 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. gitDir="$1"
  3. recentCommit="$2"
  4. experienceDir="$3"
  5. if [ ! -z "$(ls -A "$experienceDir")" ] ; then
  6. echo "experience dir is not empty: $experienceDir"
  7. exit 1
  8. fi
  9. count=0
  10. echo "counting commits..."
  11. maxCount=$(git -C "$gitDir" log --full-history --no-merges --use-mailmap --format='format:' "$recentCommit" | wc -l)
  12. (git -C "$gitDir" log --full-history --reverse --no-merges --use-mailmap --format='format:%ct %H %aN <%aE>' "$recentCommit" | sort -n | cut -f2,3; echo) | while IFS= read commit
  13. do
  14. echo -ne "commit $count / $maxCount\r"
  15. #echo "commit: $commit"
  16. author=$(echo "$commit" | cut -f2 | tr '/' '_')
  17. #echo "author: $author"
  18. commit_hash=$(echo "$commit" | cut -f1)
  19. if [ ! -z "$author" ] ; then
  20. echo "$commit_hash,$count" >> "$experienceDir/$author"
  21. fi
  22. count=$(($count + 1))
  23. done
  24. echo