-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathx-fp
executable file
·209 lines (181 loc) · 5.45 KB
/
x-fp
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
#
# Prepare topic for the upstream submission.
# The flow is different for RDMA and other submissions
# > 1 patch:
# - for rdma-rc/rdma-next needs tag to take cover letter from there
# - for other patches leaves cover letter empty, to be filled
# == 1 patch:
# - don't create cover letter
#
if [ "$#" -gt 3 ]; then
echo "Usage: x fp <start commit sha1> <tag|end commit> [ver]"
echo " <start commit sha1> should be in upstream branch"
echo " <tag> is needed for rdma-rc/rdma-next for patch "
echo " series which requires cover letter"
echo " <end commit> if omitted it will be single patch"
exit 1
fi
. $HOME/.x-tools
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/common
if [ "$#" -eq 0 ]; then
START=$(git rev-parse --verify --short=12 HEAD)
SINGLE_COMMIT=1
COMMIT_RANGE="$START"
VER_NUMB=0
VER=""
fi
if [ "$#" -eq 1 ]; then
get_arg_type $1
SINGLE_COMMIT=1
if [ r"$REPLY" == r"SHA" ]; then
START=$(git rev-parse --verify --short=12 $1)
VER_NUMB=0
VER=""
fi
if [ r"$REPLY" == r"VER" ]; then
START=$(git rev-parse --verify --short=12 HEAD)
VER_NUMB=$1
VER=" v$VER_NUMB"
fi
if [[ r"$REPLY" != r"SHA" && r"$REPLY" != r"VER" ]]; then
echo "Unsupported option. Exiting ..."
exit
fi
COMMIT_RANGE="$START"
fi
if [ "$#" -eq 2 ]; then
get_arg_type $1
if [ r"$REPLY" == r"SHA" ]; then
START=$(git rev-parse --verify --short=12 $1)
else
echo "Unsupported option. Exiting ..."
exit
fi
get_arg_type $2
if [ r"$REPLY" == r"SHA" ]; then
END=$(git rev-parse --verify --short=12 $2)
VER_NUMB=0
VER=""
COMMIT_RANGE="$START..$END"
if [ $(git rev-list --count $COMMIT_RANGE) -eq 1 ]; then
SINGLE_COMMIT=1
else
SINGLE_COMMIT=0
fi
fi
if [ r"$REPLY" == r"VER" ]; then
VER_NUMB=$2
VER=" v$VER_NUMB"
COMMIT_RANGE="$START"
SINGLE_COMMIT=1
fi
if [[ r"$REPLY" != r"SHA" && r"$REPLY" != r"VER" ]]; then
echo "Unsupported option. Exiting ..."
exit
fi
fi
if [ "$#" -eq 3 ]; then
get_arg_type $1
SINGLE_COMMIT=0
if [ r"$REPLY" == r"SHA" ]; then
START=$(git rev-parse --verify --short=12 $1)
else
echo "Unsupported option. Exiting ..."
exit
fi
get_arg_type $2
if [ r"$REPLY" == r"SHA" ]; then
END=$(git rev-parse --verify --short=12 $2)
COMMIT_RANGE="$START..$END"
if [ $(git rev-list --count $COMMIT_RANGE) -eq 1 ]; then
SINGLE_COMMIT=1
fi
else
echo "Unsupported option. Exiting ..."
exit
fi
get_arg_type $3
if [ r"$REPLY" == r"VER" ]; then
VER_NUMB=$3
VER=" v$VER_NUMB"
fi
if [ r"$REPLY" != r"VER" ]; then
echo "Unsupported option. Exiting ..."
exit
fi
fi
RDMA_TAG=0
get_project $PWD
PROJECT=$REPLY
get_target $PROJECT
TARGET=$REPLY
DIRECTORY="$PATCHES_DIR/$TARGET/$START/$VER_NUMB"
if [ -d "$DIRECTORY" ]; then
echo "$DIRECTORY exists, exiting ...."
exit 1
fi
mkdir -p $DIRECTORY/
CCLIST=$(mktemp)
# Generate CC-list
git show -s $COMMIT_RANGE | grep "\-by\:" | awk -F": " '{print $2}' >> $CCLIST
# Add author of "Fixes" commit
COUNT_FIXES=$(git show -s $COMMIT_RANGE | grep "Fixes: " | awk '{print $2}' | sort | uniq | wc -l)
if [ $COUNT_FIXES -ne 0 ]; then
git show -s $COMMIT_RANGE | grep "Fixes: " | awk '{print $2}' | sort | uniq | xargs git show --pretty=format:"%aN <%aE>" -s >> $CCLIST
echo "" >> $CCLIST
fi
if [ "$TARGET" == "rdma-next" ] || [ "$TARGET" == "rdma-rc" ] || [ "$TARGET" == "rdma-core" ]; then
TO="--to=Doug Ledford <[email protected]>, Jason Gunthorpe <[email protected]>"
LIST="RDMA mailing list <[email protected]>"
fi
if [ "$TARGET" == "iproute2-next" ]; then
TO="--to=David Ahern <[email protected]>"
echo "Stephen Hemminger <[email protected]>" >> $CCLIST
echo "RDMA mailing list <[email protected]>" >> $CCLIST
LIST="netdev <[email protected]>"
fi
if [ "$TARGET" == "iproute2-rc" ]; then
TO="--to=Stephen Hemminger <[email protected]>"
echo "David Ahern <[email protected]>" >> $CCLIST
echo "RDMA mailing list <[email protected]>" >> $CCLIST
LIST="netdev <[email protected]>"
fi
sort -uo $CCLIST $CCLIST
CC="--cc="
while IFS= read -r var
do
# Need to replace for actual author
if [[ $var != *"Romanovsky"* ]]; then
LIST=$LIST", "$var
fi
done < "$CCLIST"
CC=$CC$LIST
if [ $SINGLE_COMMIT -eq 1 ]; then
git format-patch "$TO" "$CC" -M -C --no-cover-letter --no-signoff --subject-prefix "PATCH $TARGET$VER" -o $DIRECTORY/ -1 $COMMIT_RANGE
else
git format-patch "$TO" "$CC" -M -C --cover-letter --no-signoff --subject-prefix "PATCH $TARGET$VER" -o $DIRECTORY/ $COMMIT_RANGE
fi
if [ $RDMA_TAG -eq 1 ]; then
TITLE=$(git show tags/$TAG --oneline | head -n 3 | tail -n 1)
sed -i "s/\*\*\* SUBJECT HERE \*\*\*/$TITLE/g" $DIRECTORY/0000-cover-letter.patch
CONF=$(mktemp)
git show --oneline tags/$TAG | sed -e '/-----BEGIN PGP SIGNATURE-----/,$d' | tail -n +5 >> $CONF
echo "" >> $CONF
echo "The patches are available in the git repository at:" >> $CONF
echo " git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git tags/$TAG" >> $CONF
echo "" >> $CONF
echo " Thanks" >> $CONF
echo "---------------------------------------" >> $CONF
sed -i "/\*\*\* BLURB HERE \*\*\*/r $CONF" $DIRECTORY/0000-cover-letter.patch
sed -i "/\*\*\* BLURB HERE \*\*\*/d" $DIRECTORY/0000-cover-letter.patch
fi
change_target $DIRECTORY/ $PROJECT
checkpatch $DIRECTORY/ $PROJECT
rm -rf $CCLIST
rm -rf $CONF
rm -f $DIRECTORY/latest
ln -sr $DIRECTORY $DIRECTORY/../latest
echo "-----------------------------------------------------------------------"
echo "x sync pull && git send-upstream $TARGET/$START/$VER_NUMB/*"