-
Notifications
You must be signed in to change notification settings - Fork 2
/
x-mutt2git
executable file
·47 lines (39 loc) · 1.05 KB
/
x-mutt2git
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
#!/bin/bash
#
# Grab patch from mutt and apply to local/remote git
if [ "$#" -gt 2 ]; then
echo "Usage: x mutt2git <local|remote>"
exit 1
fi
if [[ "$1" != "local" && "$1" != "remote" ]]; then
echo "Illegal parameter"
exit 1
fi
. $HOME/.x-tools
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/common
PATCH=$(mktemp)
cat - > $PATCH
sed -i -e '/^Issue:[ 0-9]*/Id' -e '/^Change-id:[ 0-9]*/Id' $PATCH
COUNT=$(grep PATCH $PATCH | grep Subject | grep -c rdma-core)
if [ $COUNT -eq 1 ]; then
PRJ="rdma-core"
else
COUNT=$(grep PATCH $PATCH | grep Subject | grep -c iproute)
if [ $COUNT -eq 1 ]; then
PRJ="iproute2"
else
PRJ="kernel"
fi
fi
if [ "$1" == "local" ]; then
echo "Applying to $X_SRC/$PRJ"
cd $X_SRC/$PRJ
git am -s --reject $PATCH
else
echo "Applying to $X_SYNC_REMOTE_SERVER:/images/leonro/src/$PRJ"
scp $PATCH $X_SYNC_REMOTE_SERVER:/tmp/
ssh $X_SYNC_REMOTE_SERVER "cd /images/leonro/src/$PRJ && git am -s --reject /tmp/$(basename $PATCH)"
ssh $X_SYNC_REMOTE_SERVER rm -f /tmp/$(basename $PATCH)
fi
rm -f $PATCH