show-fixed-bugs.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/sh
  2. # This script checks the git log for URLs to the QEMU launchpad bugtracker
  3. # and optionally checks whether the corresponding bugs are not closed yet.
  4. show_help () {
  5. echo "Usage:"
  6. echo " -s <commit> : Start searching at this commit"
  7. echo " -e <commit> : End searching at this commit"
  8. echo " -c : Check if bugs are still open"
  9. echo " -b : Open bugs in browser"
  10. }
  11. while getopts "s:e:cbh" opt; do
  12. case "$opt" in
  13. s) start="$OPTARG" ;;
  14. e) end="$OPTARG" ;;
  15. c) check_if_open=1 ;;
  16. b) show_in_browser=1 ;;
  17. h) show_help ; exit 0 ;;
  18. *) echo "Use -h for help." ; exit 1 ;;
  19. esac
  20. done
  21. if [ "x$start" = "x" ]; then
  22. start=$(git tag -l 'v[0-9]*\.[0-9]*\.0' | tail -n 2 | head -n 1)
  23. fi
  24. if [ "x$end" = "x" ]; then
  25. end=$(git tag -l 'v[0-9]*\.[0-9]*\.0' | tail -n 1)
  26. fi
  27. if [ "x$start" = "x" ] || [ "x$end" = "x" ]; then
  28. echo "Could not determine start or end revision ... Please note that this"
  29. echo "script must be run from a checked out git repository of QEMU."
  30. exit 1
  31. fi
  32. echo "Searching git log for bugs in the range $start..$end"
  33. urlstr='https://bugs.launchpad.net/\(bugs\|qemu/+bug\)/'
  34. bug_urls=$(git log $start..$end \
  35. | sed -n '\,'"$urlstr"', s,\(.*\)\('"$urlstr"'\)\([0-9]*\).*,\2\4,p' \
  36. | sort -u)
  37. echo Found bug URLs:
  38. for i in $bug_urls ; do echo " $i" ; done
  39. if [ "x$check_if_open" = "x1" ]; then
  40. echo
  41. echo "Checking which ones are still open..."
  42. for i in $bug_urls ; do
  43. if ! curl -s -L "$i" | grep "value status" | grep -q "Fix Released" ; then
  44. echo " $i"
  45. final_bug_urls="$final_bug_urls $i"
  46. fi
  47. done
  48. else
  49. final_bug_urls=$bug_urls
  50. fi
  51. if [ "x$final_bug_urls" = "x" ]; then
  52. echo "No open bugs found."
  53. elif [ "x$show_in_browser" = "x1" ]; then
  54. # Try to determine which browser we should use
  55. if [ "x$BROWSER" != "x" ]; then
  56. bugbrowser="$BROWSER"
  57. elif command -v xdg-open >/dev/null 2>&1; then
  58. bugbrowser=xdg-open
  59. elif command -v gnome-open >/dev/null 2>&1; then
  60. bugbrowser=gnome-open
  61. elif [ "$(uname)" = "Darwin" ]; then
  62. bugbrowser=open
  63. elif command -v sensible-browser >/dev/null 2>&1; then
  64. bugbrowser=sensible-browser
  65. else
  66. echo "Please set the BROWSER variable to the browser of your choice."
  67. exit 1
  68. fi
  69. # Now show the bugs in the browser
  70. first=1
  71. for i in $final_bug_urls; do
  72. "$bugbrowser" "$i"
  73. if [ $first = 1 ]; then
  74. # if it is the first entry, give the browser some time to start
  75. # (to avoid messages like "Firefox is already running, but is
  76. # not responding...")
  77. sleep 4
  78. first=0
  79. fi
  80. done
  81. fi