muttdebug by marc haber
authorStefano Zacchiroli <zack@debian.org>
Thu, 31 Jan 2008 14:17:12 +0000 (15:17 +0100)
committerStefano Zacchiroli <zack@debian.org>
Thu, 31 Jan 2008 14:17:12 +0000 (15:17 +0100)
blog/posts/2008/01/bts_followup/discussion/muttdebbug [new file with mode: 0755]

diff --git a/blog/posts/2008/01/bts_followup/discussion/muttdebbug b/blog/posts/2008/01/bts_followup/discussion/muttdebbug
new file mode 100755 (executable)
index 0000000..f8c9511
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+# by Marc Haber, see the discussion page of
+# http://upsilon.cc/~zack/blog/posts/2008/01/bts_followup/
+
+##+# todo: issue package command before tags
+
+BUGNR="$@"
+
+set -e
+
+if [ -z "$BUGNR" ]; then
+  echo >&2 "ERR: no bug number given"
+  exit 1
+fi
+
+MAILBOX="$(tempfile --prefix=mdbbg)"
+> $MAILBOX
+TOHDR="To: "
+TAGS=""
+SEVERITY=""
+
+SUMMARY="$(tempfile --prefix=mdbsu)"
+
+for bug in $BUGNR; do
+  #lynx --dump --dont-wrap-pre "http://bugs.debian.org/mbox:bug" >> $MAILBOX
+  curl --location --silent "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=$bug&mbox=yes&boring=yes" >> $MAILBOX
+  if rsync "bugs-mirror.debian.org::bts-spool-db/$(echo $bug | sed 's/.*\([0-9][0-9]\)/\1/')/$bug.summary" $SUMMARY 2>/dev/null >/dev/null; then
+    #cat $SUMMARY
+    THIS_SEVERITY="$(< $SUMMARY sed -n '/^Severity: /{s/^Severity: \([a-z]\+\).*/\1/;p;q;}')"
+    if [ -z "$THIS_SEVERITY" ]; then
+      THIS_SEVERITY="normal"
+    fi
+    SEVERITY="$SEVERITY $THIS_SEVERITY "
+    TAGS="${TAGS}tags #$bug $(< $SUMMARY sed -n '/^Tags: /{s/^Tags: \([-a-z[:space:]0-9]\+\).*/\1/;p;q;}')\n"
+  fi
+  TOHDR="${TOHDR} $bug@bugs.debian.org, $bug-submitter@bugs.debian.org,"
+  rm -f $SUMMARY
+done
+
+EXPLAIN="bug"
+
+if [ -n "$SEVERITY" ]; then
+  case "$SEVERITY" in
+    *\ critical\ *)       SEVERITY="critical";;
+    *\ grave\ *)          SEVERITY="grave";;
+    *\ serious\ *)        SEVERITY="serious";;
+    *\ important\ *)      SEVERITY="important";;
+    *\ does-not-build\ *) SEVERITY="does-not-build";;
+    *\ normal\ *)         SEVERITY="normal";;
+    *\ minor\ *)          SEVERITY="minor";          EXPLAIN="issue";;
+    *\ wishlist\ *)       SEVERITY="wishlist";       EXPLAIN="item";;
+    *) echo >&2 "ERR: illegal severity"; exit 1;;
+  esac
+else
+  SEVERITY=""
+  EXPLAIN="issue ticket"
+fi
+
+mutt -f $MAILBOX -e "my_hdr ${TOHDR%,}" \
+                 -e "my_hdr Bcc: control@bugs.debian.org" \
+                 -e "my_hdr Cc: Marc Haber <mh+debian-packages@zugschlus.de>" \
+                -e "my_hdr From: Marc Haber <mh+debian-packages@zugschlus.de>" \
+                -e "set reply_regexp=\"^(re([\[0-9\]+])*|aw):[ \t]*Bug#[0-9]*:[ \t]*\"" \
+                -e "set forward_format=\"[Debian $SEVERITY $EXPLAIN #$BUGNR] %s\"" \
+                -e "set attribution=\"${TAGS}thanks\n\nOn %d, %n wrote:\""
+rm -f $MAILBOX