diff options
| author | Carlos Maiolino <[email protected]> | 2025-11-27 10:14:39 +0100 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-11-27 10:14:39 +0100 |
| commit | 2a3f0db27360e40ebce504c0f95973b27f6ee3a0 (patch) | |
| tree | 2bd8bcfe8a0855b25f954762692be9b382485df3 /maintainer/mutt-hooks | |
| parent | 84fc31e1f824c9eccfd622eb7d89692a9357b3d7 (diff) | |
Add new mutt-hook to pull patches
Wiring it up into mutt should turn applying patches into a single click
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'maintainer/mutt-hooks')
| -rwxr-xr-x | maintainer/mutt-hooks/b4-shazam.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/maintainer/mutt-hooks/b4-shazam.sh b/maintainer/mutt-hooks/b4-shazam.sh new file mode 100755 index 0000000..4920658 --- /dev/null +++ b/maintainer/mutt-hooks/b4-shazam.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +REPO_DIR=/home/cem/Source/MAINTAINER/xfs-linux +FORMAIL=$(which formail) +B4=$(which b4) + +_die() { + echo $1 + exit 1 +} + +check_env() { + + if [ ! -d $REPO_DIR ]; then + _die "Linux repo does not exist" + fi + + if [ -z $FORMAIL ]; then + _die "Formail program missing" + fi + + if [ -z $B4 ]; then + _die "b4 program missing" + fi +} + +shazam_message() { + local MSG_ID=$1 + local CUR_DIR=$PWD + + cd $REPO_DIR + + $B4 shazam -s $MSG_ID + + if [ $? -ne 0 ]; then + cd $CUR_DIR + _die "Failed to apply $MSG_ID" + fi + + cd $CUR_DIR + echo "Message/Series $MSG_ID applied" +} + +check_env + +MSG="" + +if [ ! -t 0 ]; then + MSG=$(cat) +else + _die "No email has been piped" +fi + +# Quote $MSG to trick the shell's IFS +MESSAGE_ID=$(echo "$MSG" | formail -x message-id | sed 's/[<>]//g') + +if [ -z $MESSAGE_ID ]; then + _die "Message is empty" +fi + +shazam_message $MESSAGE_ID |
