compare_results.sh 921 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. issuesFile="$1"
  3. resultsFile="$2"
  4. bugzillaDir="$3/bugs/"
  5. bugToIntroDir="$4"
  6. fixes=$(jq 'map(.[0]) | unique' "$resultsFile" | grep -Eo '[[:alnum:]]+')
  7. for fix in $fixes ; do
  8. bug=$(jq "to_entries[] | select(.value.\"hash\" == \"$fix\") | .key" "$issuesFile" | tr -dc [0-9])
  9. blamed=$(jq "unique | .[] | select(.[0] == \"$fix\")[1]" "$resultsFile" | tr -d '"')
  10. if [ -f "$bugzillaDir/$bug.json" ] ; then
  11. groundTruth=$(jq '.inducedBy | map(.revisions)[]' "$bugzillaDir/$bug.json" | grep -Eo '[[:alnum:]]+')
  12. match=0
  13. for commit in $blamed ; do
  14. if grep -q "$commit" <(echo $groundTruth) ; then ((match++)) ; fi
  15. done
  16. szz=$(echo "$blamed" | wc -w)
  17. form=$(echo "$groundTruth" | wc -w)
  18. echo "$bug,$fix,$szz,$match,$form"
  19. echo "$groundTruth" > "$bugToIntroDir/$bug"
  20. else
  21. echo "$blamed" > "$bugToIntroDir/$bug"
  22. fi
  23. done