From 505ac26c4ca50b9f7bdf62595d679b2f32d48d82 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 24 Jul 2018 12:39:43 +0800 Subject: new script: notmuch-slurp-debbug Signed-off-by: Sean Whitton --- notmuch-slurp-debbug | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 notmuch-slurp-debbug (limited to 'notmuch-slurp-debbug') diff --git a/notmuch-slurp-debbug b/notmuch-slurp-debbug new file mode 100755 index 0000000..f92beda --- /dev/null +++ b/notmuch-slurp-debbug @@ -0,0 +1,64 @@ +#!/bin/sh + +# notmuch-slurp-debbug -- add messages from a Debian bug to notmuch + +# Copyright (C) 2018 Sean Whitton +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e + +if [ $# != 1 ]; then + echo >&2 "$0: usage: $0 BUGNUMBER" + exit 1 +fi + +if ! which notmuch >/dev/null 2>&1; then + echo >&2 "$0: error: this script requires notmuch to be installed" + exit 1 +fi + +if ! which bts >/dev/null 2>&1; then + echo >&2 "$0: error: this script requires the devscripts package" + exit 1 +fi + +bug="$1" +dest="$(notmuch config get database.path)" +# ^ this is guaranteed to be a maildir, despite the name + +bts --mbox --mailreader 'true %s' show "$bug" +# ^ see #904182 (try using this script ;)) + +temp="$(mktemp -d)" +mkdir $temp/new $temp/cur $temp/tmp + +# note that mb2md won't work; it thinks Debian BTS mboxes contain just +# a single message +mbox2maildir "${XDG_CACHE_HOME:-$HOME/.cache}"/devscripts/bts/"$bug".mbox \ + "$temp" + +for f in $temp/*/*; do + message_id="$(grep -E -i -m 1 -e '^Message-ID:' $f \ + | cut -d\ -f2 \ + | sed -e 's///')" + match="$(notmuch search --limit=1 id:$message_id | wc -l)" + if [ "$match" = "0" ]; then + mdmv "$f" "$DEST" + fi +done + +rm -rf "$temp" + +notmuch new -- cgit v1.2.3