Received: from eggs.gnu.org ([2001:4830:134:3::10]:34002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjpx6-0001kv-Jc for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:48:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjpx2-0001wb-Jq for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:48:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52370) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjpx2-0001uW-Bu for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:48:48 -0400 References: <1473772858-30881-1-git-send-email-thuth@redhat.com> From: Eric Blake Message-ID: <64a69157-6f90-dd7d-e1bc-9b319b91ec55@redhat.com> Date: Tue, 13 Sep 2016 10:48:46 -0500 MIME-Version: 1.0 In-Reply-To: <1473772858-30881-1-git-send-email-thuth@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="E8uBo101hHflqj3c8dS5pxfg2LanO8thI" Subject: Re: [Qemu-devel] [PATCH v2] scripts: Add a script to check for bug URLs in the git log List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth , qemu-devel@nongnu.org Cc: Peter Maydell , stefanha@redhat.com, Paolo Bonzini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --E8uBo101hHflqj3c8dS5pxfg2LanO8thI From: Eric Blake To: Thomas Huth , qemu-devel@nongnu.org Cc: Peter Maydell , stefanha@redhat.com, Paolo Bonzini Message-ID: <64a69157-6f90-dd7d-e1bc-9b319b91ec55@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2] scripts: Add a script to check for bug URLs in the git log References: <1473772858-30881-1-git-send-email-thuth@redhat.com> In-Reply-To: <1473772858-30881-1-git-send-email-thuth@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/13/2016 08:20 AM, Thomas Huth wrote: > 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". >=20 > Signed-off-by: Thomas Huth > --- > v2: > - Use xdg-open and friends to open the URLs in a browser > - Some cosmetics >=20 > scripts/show-fixed-bugs.sh | 91 ++++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 91 insertions(+) > create mode 100755 scripts/show-fixed-bugs.sh >=20 > diff --git a/scripts/show-fixed-bugs.sh b/scripts/show-fixed-bugs.sh > new file mode 100755 > index 0000000..89847bd > --- /dev/null > +++ b/scripts/show-fixed-bugs.sh > @@ -0,0 +1,91 @@ > +#!/bin/sh > + > +# This script checks the git log for URLs to the QEMU launchpad bugtra= cker > +# and optionally checks whether the corresponding bugs are not closed = yet. > + > +function show_help { > + echo "Usage:" > + echo " -s : Start searching at this commit" > + echo " -e : End searching at this commit" > + echo " -c : Check if bugs are still open" > + echo " -b : Open bugs in browser" > +} > + > +while [ $# -ge 1 ]; do > + case "$1" in > + -s) START=3D"$2" ; shift ;; POSIX recommends that short options with arguments be parseable both as '-s foo' and '-sfoo'. I don't care that you aren't POSIX compliant, but using getopt(1) or getopts(1) may make it easier to comply. Using ALL_CAPS variables in a shell script risks collisions with environment variables that might have other uses. It may be better to use lower case variables to make it obvious that they are for internal us= e. > + -e) END=3D"$2" ; shift ;; > + -c) CHECK_IF_OPEN=3D1 ;; > + -b) SHOW_IN_BROWSER=3D1 ;; > + -h) show_help ; exit 0 ;; > + *) echo "Unkown option $1 ... use -h for help." ; exit 1 ;; s/Unkown/Unknown/ > + esac > + shift > +done > + > +if [ "x$START" =3D "x" ]; then > + START=3D`git tag | grep 'v[0-9]*\.[0-9]*.0$' | tail -n 2 | head -n= 1` You can shorten 'git tag | grep' via: git tag -l 'v[0-9]*.[0-9]*.0' > +fi > +if [ "x$END" =3D "x" ]; then > + END=3D`git tag | grep 'v[0-9]*\.[0-9]*.0$' | tail -n 1` and again > +fi > + > +if [ "x$BROWSER" !=3D "x" ]; then > + BUGBROWSER =3D "$BROWSER" > +elif which xdg-open > /dev/null; then 'which' is not portable; it may not exist. It looks like you are trying to redirect to /dev/null to avoid shell messages when it does not exist, but to properly do that, you'd need: (which xdg-open) >/dev/null 2>&1 (the subshell is necessary, since some shells don't shut up without it). > + BUGBROWSER=3Dxdg-open > +elif which gnome-open > /dev/null; then > + BUGBROWSER=3Dgnome-open and again > +elif [ `uname` =3D "Darwin" ]; then > + BUGBROWSER=3Dopen Improperly quoted. You want "`uname`" to make sure that random spaces don't cause the wrong number of arguments to '['. > +elif which sensible-browser > /dev/null; then > + BUGBROWSER=3Dsensible-browser another nonportable which. > +else > + echo "Please set the BROWSER variable to the browser of your choic= e." > + exit 1 > +fi > + > +if [ "x$START" =3D "x" -o "x$END" =3D "x" ]; then [ ... -o ... ] is not portable. POSIX itself recommends that you use: [ "x$START" =3D "x" ] || [ "x$END" =3D "x" ] > + echo "Could not determine start or end revision ... Please note th= at 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=3D`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,' \ 'grep | sed' can usually be shortened to just 'sed'. Here, it could be: str=3D'https://bugs.launchpad.net,\(bugs\|qemu/+bug\)' sed -n '\,'"$str"', s,\(.*\)\('"$str"'/\)\([0-9]*\).*,\2\4,p' > + | sort -u` > + > +echo Found bug URLs: > +for i in $BUG_URLS ; do echo " $i" ; done > + > +if [ "x$CHECK_IF_OPEN" =3D "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 Rele= ased" ; then > + echo " $i" > + FINAL_BUG_URLS=3D"$FINAL_BUG_URLS $i" > + fi > + done > +else > + FINAL_BUG_URLS=3D$BUG_URLS > +fi > + > +if [ "x$FINAL_BUG_URLS" =3D "x" ]; then > + echo "No open bugs found." > +elif [ "x$SHOW_IN_BROWSER" =3D "x1" ]; then > + FIRST=3D1 > + for i in $FINAL_BUG_URLS; do > + "$BUGBROWSER" "$i" > + if [ $FIRST =3D 1 ]; then > + # if it is the first entry, give the browser some time to = start > + # (to avoid messages like "Firefox is already running, but= is > + # not responding...") > + sleep 4 > + FIRST=3D0 > + fi > + done > +fi >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --E8uBo101hHflqj3c8dS5pxfg2LanO8thI Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX2B/eAAoJEKeha0olJ0NqPkUIAJEkCa/9FcopANSEh1FwTEt8 RA6XB+cW23gwfK/lYWjqva26C4vhmWHqFfTvrsi2mNhdDedf2vpPLKL7Z/7p/4Z5 9Uce95XLFgHOLMT3Xat9EOpeQ6cCS/1Gx0SsQk98Jgr+OhR0EKWAc6M+zk1g0NcN 7draZAW8z5Zp0PhhvZwLupWdrjYybEkwUS9TQp5KHMa4roZzAdywdM1+1GehVCmr CgtFjmrlko+rMPTDR8J91wm+MlXL67d45CCoXVBtmMXNmsq4ps5Yv01FdLxgfMmc SZgUEK13W2OmMUTiv8RN+4hzEptsNYDVDI3iyJjMXVZGsk4ixk2VF4GvbMEmCwA= =RJWY -----END PGP SIGNATURE----- --E8uBo101hHflqj3c8dS5pxfg2LanO8thI--