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