diff mbox

[RFC] scripts: Add a script to check for bug URLs in the git log

Message ID 1467029649-26621-1-git-send-email-thuth@redhat.com
State New
Headers show

Commit Message

Thomas Huth June 27, 2016, 12:14 p.m. UTC
Basic idea of this script is to check the git log for URLs
to the QEMU bugtracker at launchpad.net and to figure out
whether the related bug has been marked there as "Fix released"
(i.e. closed) already. So this script can e.g. be used after
each public release of QEMU to check whether there are any
bug tickets that could be moved from "Fix committed" (or another
state if the author of the patch forgot to update the bug ticket)
to "Fix released".

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 Note: I'm sending this as an RFC patch only since I'm not sure whether we
 want to have such "quick-n-dirty" scripts in the repository (yeah, I'm a
 C programmer, not a shell script hacker!). Anyway, the script was quite
 helpful to me already during the last week to find some bugs at LP which
 could definitely be closed, so I thought I'd send this to the list now
 instead of letting it collect dust on my hard disk.

 scripts/check-fixed-bugs.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100755 scripts/check-fixed-bugs.sh

Comments

Stefan Hajnoczi June 28, 2016, 9:24 a.m. UTC | #1
On Mon, Jun 27, 2016 at 02:14:09PM +0200, Thomas Huth wrote:
> +function show_help {
> +    echo "Usage:"
> +    echo "  -s <commit>  : Start searching by this commit"

s/by/at/

> +    echo "  -e <commit>  : End searching by this commit"

s/by/at/

> +    echo "  -c           : Check if bugs are still open"
> +    echo "  -b           : Open bugs in browser (firefox by default)"

Use xdg-open(1) on Linux and open(1) on Mac OS X to open a URL with the
default browser.
Peter Maydell June 28, 2016, 10:03 a.m. UTC | #2
On 28 June 2016 at 10:24, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Mon, Jun 27, 2016 at 02:14:09PM +0200, Thomas Huth wrote:
>> +function show_help {
>> +    echo "Usage:"
>> +    echo "  -s <commit>  : Start searching by this commit"
>
> s/by/at/
>
>> +    echo "  -e <commit>  : End searching by this commit"
>
> s/by/at/
>
>> +    echo "  -c           : Check if bugs are still open"
>> +    echo "  -b           : Open bugs in browser (firefox by default)"
>
> Use xdg-open(1) on Linux and open(1) on Mac OS X to open a URL with the
> default browser.

On Debian and ubuntu 'sensible-browser' is in a priority:required
package, but xdg-open is in a priority:optional one...

thanks
-- PMM
diff mbox

Patch

diff --git a/scripts/check-fixed-bugs.sh b/scripts/check-fixed-bugs.sh
new file mode 100755
index 0000000..4255de6
--- /dev/null
+++ b/scripts/check-fixed-bugs.sh
@@ -0,0 +1,71 @@ 
+#!/bin/sh
+
+# This script checks the git log for URLs to the QEMU launchpad bugtracker
+# and optionally checks whether the corresponding bugs are not closed yet.
+
+function show_help {
+    echo "Usage:"
+    echo "  -s <commit>  : Start searching by this commit"
+    echo "  -e <commit>  : End searching by this commit"
+    echo "  -c           : Check if bugs are still open"
+    echo "  -b           : Open bugs in browser (firefox by default)"
+}
+
+while [ $# -ge 1 ]; do
+   case "$1" in
+    -s)  START="$2" ; shift ;;
+    -e)  END="$2" ; shift ;;
+    -c)  CHECK_IF_OPEN=1 ;;
+    -b)  SHOW_IN_BROWSER=1 ;;
+    -h)  show_help ; exit 0 ;;
+    *)   echo "Unkown option $1 ... use -h for help." ; exit 1 ;;
+   esac
+   shift
+done
+
+if [ "x$START" = "x" ]; then
+    START=`git tag | grep 'v[0-9]*\.[0-9]*.0$' | tail -n 2 | head -n 1`
+fi
+if [ "x$END" = "x" ]; then
+    END=`git tag | grep 'v[0-9]*\.[0-9]*.0$' | tail -n 1`
+fi
+if [ "x$BROWSER" = "x" ]; then
+    BROWSER=firefox
+fi
+
+if [ "x$START" = "x" -o "x$END" = "x" ]; then
+    echo "Could not determine start or end revision ... Please note that this"
+    echo "script must be run from a checked out git repository of QEMU!"
+    exit 1
+fi
+
+echo "Searching git log for bugs in the range $START..$END"
+
+BUG_URLS=`git log $START..$END \
+  | grep 'https://bugs.launchpad.net/\(bugs\|qemu/+bug\)/' \
+  | sed 's,\(.*\)\(https://bugs.launchpad.net/\(bugs\|qemu/+bug\)/\)\([0-9]*\).*,\2\4,' \
+  | sort -u`
+
+echo Found bug URLs:
+for i in $BUG_URLS ; do echo " $i" ; done
+
+if [ "x$CHECK_IF_OPEN" = "x1" ]; then
+    echo
+    echo "Checking which ones are still opened..."
+    for i in $BUG_URLS ; do
+        if ! curl -s -L $i | grep "value status" | grep -q "Fix Released" ; then
+            echo " $i"
+            FINAL_BUG_URLS="$FINAL_BUG_URLS $i"
+        fi
+    done
+else
+    FINAL_BUG_URLS=$BUG_URLS
+fi
+
+if [ "x$FINAL_BUG_URLS" = "x" ]; then
+    echo "No bugs found."
+else
+    if [ "x$SHOW_IN_BROWSER" = "x1" ]; then
+        $BROWSER $FINAL_BUG_URLS
+    fi
+fi