fetch-all-approval-reqs.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. issuesFile=$1
  2. firefoxDir=$2
  3. bugzillaDir=$3
  4. codeDir=$4
  5. gitDir="$firefoxDir/.git"
  6. mkdir -p "$bugzillaDir/bugs"
  7. bugs=$(jq 'keys' "$issuesFile" | grep -Eo '[0-9]+')
  8. for bug in $bugs; do
  9. causes=$(python3 "$codeDir/fetch_bugzilla_bugs/get-approval-request-comment.py" $bug)
  10. if [ "$causes" ] ; then
  11. causes=$(echo $causes | tr -dc '0-9 ')
  12. # grep -v for long indentation because it's easier if we construct the "inducedBy" field ourselves
  13. grep -v ' ' "$bugzillaDir/template.json" > "$bugzillaDir/bugs/$bug.json"
  14. sed -i "s/^ \"id\": \"\",/ \"id\": \"$bug\",/" "$bugzillaDir/bugs/$bug.json"
  15. comma=""
  16. for cause in $causes ; do
  17. causeRevs=""
  18. causeRevs=$(python3 "$codeDir/fetch_bugzilla_bugs/get_bugzilla_patches.py" 'titles' $cause |
  19. while read -r line ; do
  20. rev=$(git --git-dir "$gitDir" log --grep="$line" -F --pretty='tformat:"%H"' | tr '\n' ',' | head -c -1)
  21. if [ "$rev" ] ; then
  22. echo "$rev"
  23. fi
  24. done | tr '\n' ',' | head -c -1)
  25. sed -i "s/^ ]/$comma {\n \"id\": \"$cause\",\n \"revisions\": [$causeRevs]\n }\n ]/" "$bugzillaDir/bugs/$bug.json"
  26. comma=","
  27. done
  28. fi
  29. done