blob: e8072c1cfe402033626d044455d4486b95cf9873 (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
#!/bin/bash
# Stateless script to create stacked patch series (with guilt) on a specified
# git repository.
#
# Used mostly to help with patch maintenance on xfsprogs project.
#
# The idea is to use it as a hook in neomutt, select a bunch of patches create
# stgit series based on those.
#
# The script relies on b4 tool to create mailboxes from the patches's msg-ids,
# and those mboxes sent to stgi to transform them in patch series.
#Piped message(s)
emails=$2
#Repository to act on
REPO="$1"
patch=/tmp/$$.patch
mbox=/tmp/mutt_mbox.tmp
MBOX_DIR=/tmp/MBOX_DIR
# Logging
IMPORT_LOG=/tmp/$$.import_log
#Commands used
B4=`which b4`
GIT=`which git`
GUILT=`which guilt`
#Repositories location
KERNEL_REPO=$HOME/Source/kernel/linux.pristine
XFSPROGS_REPO=$HOME/Source/xfsprogs/xfsprogs-dev.pristine
XFSDUMP_REPO=$HOME/Source/xfsdump/xfsdump-dev.pristine
cleanup(){
rm -rf $MBOX_DIR
rm -rf $IMPORT_LOG
rm -rf /tmp/*.error_log
}
setup(){
if [ -d $MBOX_DIR ]; then
mkdir -p $MBOX_DIR
fi
}
# Create multiple mboxes from tagged messages
import_from_list(){
ID_LIST=/tmp/$$.idlist
ERR_LOG=/tmp/$$_import.error_log
cat $emails | grep Message-Id | awk '{print $2}'> $ID_LIST
for i in `cat $ID_LIST`; do
b4 -q am -t -s -o $MBOX_DIR $i &> $ERR_LOG
done
rm $ID_LIST
}
# Import patches from mailboxes into a git branch
create_git_branch(){
if [ $REPO == "xfsprogs" ]; then
cd $XFSPROGS_REPO
elif [ $REPO == "xfsdump" ]; then
cd $XFSDUMP_REPO
else
echo "Invalid repository"
exit 1
fi
for i in `ls $MBOX_DIR | grep ".mbx"`; do
series=$(echo $i | sed 's/.mbx//')
ERR_LOG=/tmp/$series.error_log
#stack=$(echo $i)
echo "====================="
echo "- Applying Series:"
echo "$series"
echo
# Ensure we are at for-next branch, to avoid stacking different
# series in the same branch
echo "- Creating new Branch:"
$GIT checkout -q -B IMPORT_$series >> $ERR_LOG
echo
echo "- Resetting branch to for-next"
$GIT reset -q --hard for-next >> $ERR_LOG
#$GIT checkout -q for-next > $ERR_LOG
echo
echo "- Importing commits"
$GIT am $MBOX_DIR/$i 2>> $ERR_LOG >> $IMPORT_LOG
#if [ $? != 0 ]; then
if [ -s $ERR_LOG ]; then
echo "GIT AM ERROR: Failed to import series: $series"
#echo "DEBUG: $MBOX_DIR/$i"
#echo "DEBUG: $PWD"
echo "See: $ERR_LOG"
$GIT am --abort >> $IMPORT_LOG
continue
else
echo
echo "-= SERIES APPLIED =-"
fi
done
echo
echo "- Moving back to master branch..."
$GIT checkout -q master >> $ERR_LOG
echo
echo "-= Job finished =-"
echo "====================="
}
show_dialog(){
dialog --clear --menu "Select reposiroty" 0 0 20 "kernel" "" "xfsprogs" "" 2>&1 >/dev/tty
}
# Prog starts here
cleanup
mkdir $MBOX_DIR
import_from_list $emails
create_git_branch
#create_patch_stacks $XFSPROGS_REPO
#create_patch_stacks $XFSDUMP_REPO
|