Package: devscripts
Version: 2.9.20
Severity: minor
File: /usr/bin/tagpending
Tags: patch

The tagpending script gives the following usage information when called
as "tagpending -v":

---------- cut here ---------
[EMAIL PROTECTED]:/data/shared/src/cyrus/trunk/cyrus-imapd-2.2.13$ tagpending -v
tagpending error: unrecognized option -v

Usage: tagpending [options]
  Options:
    -n                  Only simulate what would happen during this run, and
                        print the message that would get sent to the BTS.
    -s                  Silent mode
    -f                  Do not query the BTS for already tagged bugs (force).
    -h, --help          This usage screen.
    -v, --version       Display the version and copyright information

  This script will read debian/changelog and tag all bugs not already tagged
  pending as such.  Requires wget to be installed to query BTS.
---------- cut here ---------

Which contradicts itself.

I would suggest Making "-V" (capital v) the alias for --version like
most GNU applications do. And make "-v" an alias to "--verbose" (to be
implemented) which lists the bugs checked and tagged, like this:

checking bug #1001: already pending
checking bug #1102: tagging it
....

I attached a patch which fixes the usage stuff (also adding --noact,
--silent and --force) and implements verbose mode, which lists the bug
IDs checked.

cu,
sven
--- tagpending  2006-05-17 06:28:18.000000000 +0000
+++ tagpending  2006-09-13 15:24:32.718518080 +0000
@@ -8,12 +8,14 @@
   cat <<EOF
 Usage: tagpending [options]
   Options:
-    -n                  Only simulate what would happen during this run, and
+    -n, --noact         Only simulate what would happen during this run, and
                         print the message that would get sent to the BTS.
-    -s                  Silent mode
-    -f                  Do not query the BTS for already tagged bugs (force).
+    -s, --silent        Silent mode
+    -v, --verbose       Verbose mode: List bugs checked/tagged. 
+                        NOTE: Verbose and silent mode can't be used together.
+    -f, --force         Do not query the BTS for already tagged bugs (force).
     -h, --help          This usage screen.
-    -v, --version       Display the version and copyright information
+    -V, --version       Display the version and copyright information
 
   This script will read debian/changelog and tag all bugs not already tagged
   pending as such.  Requires wget to be installed to query BTS.
@@ -34,13 +36,15 @@
 USE_WGET=1
 DRY=0
 SILENT=0
+VERBOSE=0
 
 while [ -n "$1" ]; do
   case "$1" in
-    -n) DRY=1; shift ;;
-    -s) SILENT=1; shift ;;
-    -f) USE_WGET=0; shift ;;
-    --version) version; exit 0 ;;
+    -n|--noact) DRY=1; shift ;;
+    -s|--silent) SILENT=1; shift ;;
+    -f|--force) USE_WGET=0; shift ;;
+    -V|--version) version; exit 0 ;;
+    -v|--verbose) VERBOSE=1; shift ;;
     --help | -h) usage; exit 0 ;;
     *)
       echo "tagpending error: unrecognized option $1" >&2
@@ -51,6 +55,13 @@
   esac
 done
 
+if [ "$VERBOSE" = "1" ] && [ "$SILENT" = "1" ]; then
+    echo "tagpending error: --silent and --verbose contradict each other" >&2
+    echo
+    usage
+    exit 1
+fi
+
 if [ "$USE_WGET" = "1" ]  &&  ! command -v wget >/dev/null 2>&1; then
   echo "tagpending error: Sorry, either use the -f option or install the wget 
package." >&2
   exit 1
@@ -75,14 +86,25 @@
        sed -ne 's/.*<a href="bugreport.cgi?bug=\([0-9]*\).*/\1/; T; p')
 fi
 
-to_be_tagged=$(printf '%s\n%s\n' "$changelog_closes" "$bts_pending" | sort | 
uniq -u)
+to_be_checked=$(printf '%s\n%s\n' "$changelog_closes" "$bts_pending" | sort | 
uniq -u)
 
 # Now remove the ones tagged in the BTS but no longer in the changelog.
-to_be_tagged=$(for bug in $to_be_tagged; do
+to_be_tagged=""
+for bug in $to_be_checked; do
+  if [ "$VERBOSE" = "1" ]; then
+       echo -n "Checking bug #$bug: "
+  fi
   if ! echo "$bts_pending" | grep -q "^${bug}$"; then
-    echo "$bug"
+    if [ "$VERBOSE" = "1" ]; then
+       echo "needs tag"
+    fi
+    to_be_tagged="$to_be_tagged $bug"
+  else
+    if [ "$VERBOSE" = "1" ]; then
+       echo "already marked pending"
+    fi
   fi
-done)
+done
 
 if [ -z "$to_be_tagged" ]; then
   if [ "$SILENT" = 0 -o "$DRY" = 1 ]; then

Reply via email to