Skip to content

Instantly share code, notes, and snippets.

@bonzini
Last active February 25, 2022 14:52
Show Gist options
  • Save bonzini/cd056d0378d2482fd8553bd1722bc7ec to your computer and use it in GitHub Desktop.
Save bonzini/cd056d0378d2482fd8553bd1722bc7ec to your computer and use it in GitHub Desktop.
#! /bin/sh
if test $1 = -n; then
ARGS=--dry-run
shift
else
ARGS=--confirm=always
fi
mboxsplit() {
last=$(git mailsplit -d4 -o$1 -b -- -)
echo Sending $last thank you messages...
}
mkdir .mboxsplit || exit
trap 'st=$?; rm -rf .mboxsplit; exit $st' 0 INT TERM
patchew -s https://patchew.org search -r "$*" | jq -r '
def address: if .name then "\(.name) <\(.address)>" else .address end;
map({
"subject": .subject,
"message_id": .message_id,
"sender": .sender | address,
"recipients": .recipients | map(select(.name != "Paolo Bonzini")) | map(address) | join(", "),
}) | map([
"From - Mon Sep 17 00:00:00 2001",
"From: Paolo Bonzini <pbonzini@redhat.com>",
"To: \(.sender)",
"Cc: \(.recipients)",
"Subject: Re: \(.subject)",
"In-reply-to: <\(.message_id)>", "",
"Queued, thanks.", "",
"Paolo", "", ""
] | join("\n")) | join("")' | mboxsplit .mboxsplit
sleep 1
exec git send-email --no-thread --to '' $ARGS .mboxsplit/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment