From d0cbe54bb6e9fff72024d3e41f0d09b125a66c43 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Mon, 22 Nov 2021 14:13:25 +0100 Subject: [PATCH] mutt: add some patch cmds --- .mutt/bin/patch_apply.sh | 36 ++++++++++++++++ .mutt/bin/patch_find_project.sh | 15 +++++++ .mutt/bin/patch_lore.sh | 75 +++++++++++++++++++++++++++++++++ .muttrc | 27 ++++++++---- 4 files changed, 145 insertions(+), 8 deletions(-) create mode 100755 .mutt/bin/patch_apply.sh create mode 100755 .mutt/bin/patch_find_project.sh create mode 100755 .mutt/bin/patch_lore.sh diff --git a/.mutt/bin/patch_apply.sh b/.mutt/bin/patch_apply.sh new file mode 100755 index 0000000..29b1d43 --- /dev/null +++ b/.mutt/bin/patch_apply.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# store patch +file="$(mktemp ${TMPDIR-/tmp}/mutt-patch-apply-XXXXXXXX)" +trap "rm -f $file" EXIT +cat > "$file" + +# find project +#source ~/.mutt/bin/patch-find-project.sh +#if test "$project" = ""; then +# echo "ERROR: can't figure project" +# exit 1 +#fi +# +## go! +#clear +#cd $HOME/projects/$project +project=$(pwd) +branch=$(git rev-parse --abbrev-ref HEAD) + +clear +echo "#" +echo "# try applying patch to $project, branch $branch" +echo "#" + +if git am --message-id --3way --ignore-whitespace --whitespace=fix "$file"; then + echo "#" + echo "# OK" + echo "#" +else + echo "# FAILED, cleaning up" + cp -v .git/rebase-apply/patch patch-apply-failed.diff + cp -v "$file" patch-apply-failed.mail + git am --abort + git reset --hard +fi diff --git a/.mutt/bin/patch_find_project.sh b/.mutt/bin/patch_find_project.sh new file mode 100755 index 0000000..c33dafa --- /dev/null +++ b/.mutt/bin/patch_find_project.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +#!/bin/sh +if test "$PATCH_PROJECT" != ""; then + project="$PATCH_PROJECT" +elif grep -q -e "devel@edk2.groups.io" "$file"; then + project="edk2" +elif grep -q -e "qemu-devel@nongnu.org" "$file"; then + project="qemu" +# [ ... more checks snipped ... ] +fi +if test "$project" = ""; then + echo "Can't figure project automatically." + echo "Use env var PATCH_PROJECT to specify path." +fi diff --git a/.mutt/bin/patch_lore.sh b/.mutt/bin/patch_lore.sh new file mode 100755 index 0000000..321cf83 --- /dev/null +++ b/.mutt/bin/patch_lore.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +# store patch +file="$(mktemp ${TMPDIR-/tmp}/mutt-patch-queue-XXXXXXXX)" +trap "rm -f $file" EXIT +cat > "$file" + +# find project +source ~/.mutt/bin/patch-find-project.sh +if test "$project" = ""; then + echo "ERROR: can't figure project" + exit 1 +fi + +# find msgid +msgid=$(grep -i -e "^message-id:" "$file" | head -n 1 \ + | sed -e 's/.*.*//') + +# go! +clear +cd $HOME/projects/$project +branch=$(git rev-parse --abbrev-ref HEAD) + +clear +echo "#" +echo "# try queuing patch (series) for $project, branch $branch" +echo "#" +echo "# msgid: $msgid" +echo "#" + +# create work dir +WORK="${TMPDIR-/tmp}/${0##*/}-$$" +mkdir "$WORK" || exit 1 +trap 'rm -rf $file "$WORK"' EXIT + +echo "# fetching from lore ..." +echo "#" +b4 am --outdir "$WORK" \ + --apply-cover-trailers \ + --sloppy-trailers \ + $msgid || exit 1 + +count=$(ls $WORK/*.mbx 2>/dev/null | wc -l) +if test "$count" = "0"; then + echo "#" + echo "# got nothing, trying notmuch instead ..." + echo "#" + echo "# update db ..." + notmuch new + echo "# find thread ..." + notmuch show \ + --format=mbox \ + --entire-thread=true \ + id:$msgid > $WORK/notmuch.thread + echo "# process mails ..." + b4 am --outdir "$WORK" \ + --apply-cover-trailers \ + --sloppy-trailers \ + --use-local-mbox $WORK/notmuch.thread \ + $msgid || exit 1 + count=$(ls $WORK/*.mbx 2>/dev/null | wc -l) +fi + +echo "#" +echo "# got $count patches, trying to apply ..." +echo "#" +if git am -m -3 $WORK/*.mbx; then + echo "#" + echo "# OK" + echo "#" +else + echo "# FAILED, cleaning up" + git am --abort + git reset --hard +fi diff --git a/.muttrc b/.muttrc index 678a520..797668d 100644 --- a/.muttrc +++ b/.muttrc @@ -30,12 +30,18 @@ unset metoo ## ACCOUNT # GMAIL -set folder= imaps://imap.gmail.com:993 -set spoolfile= +INBOX #or +[Gmail]/Important -set postponed= +[Gmail]/Drafts -set imap_user = 'mathieu.maret@gmail.com' -#set imap_pass = 'yourpass' +#set folder= imaps://imap.gmail.com:99 +#set postponed= +[Gmail]/Drafts +#set imap_user = 'mathieu.maret@gmail.com' +# Mathux +set folder= imap://mathux.org:143 +set postponed= +Drafts #[Gmail]/Drafts +set imap_user = 'mathieu' +set ssl_starttls=yes + +set spoolfile= +INBOX #or +[Gmail]/Important +#set imap_pass = 'yourpass' #set record="imaps://imap.gmail.com/[Gmail]/Sent Mail" unset record set maildir_trash = yes @@ -47,7 +53,8 @@ set certificate_file=~/.mutt/certificates set imap_check_subscribed="yes" set imap_list_subscribed="yes" mailboxes ! -set smtp_url = smtp://mathieu.maret@smtp.gmail.com:587/ +#set smtp_url = smtp://mathieu.maret@smtp.gmail.com:587/ +set smtp_url = smtp://mathieu@mathux.org:587/ ## VIEW MAIL set smileys="(>From)|(:[-^]?[][)(><}{|/DP])" @@ -59,7 +66,8 @@ set pager_stop # "next_page" won't jump to next message at end of messages set edit_headers set attribution="%n wrote:" # attribution format : on day, name wrote (alias=%a if you want to add that) set indent_string="> " -set from="Mathieu Maret " +#set from="Mathieu Maret " +set from="Mathieu Maret " ## INDEX set index_format="%4C %Z [%D] %-15.15n %s" @@ -120,4 +128,7 @@ source $alias_file #macro index,pager a "abook --add-email-quiet" "Add this sender to Abook" #bind editor complete-query # -# +bind index,pager p noop # default: print +macro index,pager pp print +macro index,pager pa "~/.mutt/bin/patch_apply.sh" +macro index,pager pl "~/.mutt/bin/patch_lore.sh"