blob: 478a2763e9fff66a86aab22b787fae41161a09b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/bin/bash
REPO_DIR=/home/cem/Source/MAINTAINER/$1
FORMAIL=$(which formail)
B4=$(which b4)
_die() {
echo $1
exit 1
}
check_env() {
if [ -z $1 ]; then
_die "You must specify a branch"
fi
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 $1
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
|