forked from petervanderdoes/gitflow-avh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·311 lines (236 loc) · 5.2 KB
/
test.sh
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
#!/bin/bash
set -x -e
editor="nano"
file="log.txt"
commit_log="commits.txt"
commit_index=0
function wait_for_key() {
read -p "Press enter to continue"
}
function commit() {
local t=$1
local label=$2
local work_file="${3:-$file}"
local entry="${commit_index}: ${t}: ${label}"
echo $entry >> $work_file
git add $work_file
git commit $work_file -m "Updated ${work_file} at ${t} from ${label}"
echo $entry >> $commit_log
let "commit_index+=1"
}
function resolve()
{
sed -i '/^<<<<<<<.*$/d' log.txt
sed -i '/^=======.*$/d' log.txt
sed -i '/^>>>>>>>.*$/d' log.txt
# nano $file
git add $file
}
function resolve_and_commit() {
resolve
git commit -m "Resolved conflict."
}
function merge_and_resolve()
{
local base=$1
set +e
git merge $base
# git rebase $base
set -e
# wait_for_key
resolve_and_commit
# git rebase --continue
}
function initialise() {
local demo_dir="demo.dir"
mkdir -p $demo_dir
pushd $demo_dir > /dev/null 2>&1
rm -rf .git
git init
cat <<EOF > .gitignore
commits.txt
EOF
git add .gitignore
git commit -m "Initial commit"
rm -f $file
rm -f $commit_log
git flow init --defaults
# for branch in bugfix feature
# do
# git config gitflow.${branch}.finish.rebase yes
# done
}
## ==== ==== ==== ====
initialise
## ==== ==== ==== ====
t="t-0"
branch="develop"
git checkout $branch
git flow bugfix start "BF1"
## ==== ==== ==== ====
t="t-1"
branch="develop"
git checkout $branch
git flow feature start "F1"
branch="develop"
git checkout $branch
commit $t $branch
branch="bugfix/BF1"
git checkout $branch
git merge "develop"
commit $t $branch
branch="master"
git checkout $branch
git flow hotfix start "HF1"
## ==== ==== ==== ====
t="t-2"
branch="feature/F1"
git checkout $branch
git merge "develop"
commit $t $branch
branch="develop"
git checkout $branch
git flow feature start "F2"
branch="bugfix/BF1"
git checkout $branch
git flow bugfix finish
branch="hotfix/HF1"
git checkout $branch
commit $t $branch
## ==== ==== ==== ====
t="t-3"
branch="feature/F2"
git checkout $branch
git merge "develop"
commit $t $branch
branch="develop"
git checkout $branch
commit $t $branch
branch="hotfix/HF1"
git checkout $branch
set +e
git flow hotfix finish --tagname "1.0.1" --message "Work item $branch completed."
set -e
resolve_and_commit
git flow hotfix finish "HF1" --tagname "1.0.1" --message "Work item $branch completed."
## ==== ==== ==== ====
t="t-4"
branch="feature/F2"
git checkout $branch
merge_and_resolve "develop"
git flow feature finish
## ==== ==== ==== ====
t="t-5"
branch="develop"
git checkout $branch
git flow release start "R1"
## ==== ==== ==== ====
t="t-6"
branch="release/R1"
git checkout $branch
git flow bugfix start "BF2" $branch
## ==== ==== ==== ====
t="t-7"
branch="bugfix/BF2"
git checkout $branch
commit $t $branch
## <DF> Optional divergence of master prior to finishing release/R1
branch="master"
git checkout $branch
commit $t $branch "${branch}.txt"
## </DF>
## ==== ==== ==== ====
t="t-8"
branch="bugfix/BF2"
git checkout $branch
git flow bugfix finish
## ==== ==== ==== ====
t="t-9"
branch="release/R1"
git checkout $branch
## <DF> Required merge of master prior to finishing release
git merge "master"
## </DF>
git flow release finish --tagname "1.1.0" --message "Work item $branch completed."
## ==== ==== ==== ====
t="t-10"
branch="develop"
git checkout $branch
git flow feature start "F3"
## ==== ==== ==== ====
t="t-11"
branch="feature/F3"
git checkout $branch
git merge "develop"
commit $t $branch
## ==== ==== ==== ====
t="t-12"
branch="feature/F1"
git checkout $branch
merge_and_resolve "develop"
git flow feature finish
branch="feature/F3"
git checkout $branch
git flow feature finish
## ==== ==== ==== ====
t="t-13"
branch="develop"
git checkout $branch
git flow release start R2
## ==== ==== ==== ====
t="t-14"
branch="release/R2"
git checkout $branch
git flow release finish --tagname "1.2.0" --message "Work item $branch completed."
## ==== ==== ==== ====
t="t-15"
branch="develop"
git checkout $branch
commit $t $branch
## ==== ==== ==== ====
t="t-16"
branch="develop"
git checkout $branch
git flow release start R3
## ==== ==== ==== ====
t="t-17"
branch="release/R3"
git checkout $branch
git flow bugfix start "BF3" $branch
## ==== ==== ==== ====
t="t-18"
branch="bugfix/BF3"
git checkout $branch
commit $t $branch
branch="master"
git checkout $branch
git flow hotfix start "HF2"
## ==== ==== ==== ====
t="t-19"
branch="hotfix/HF2"
git checkout $branch
commit $t $branch
## ==== ==== ==== ====
t="t-20"
branch="hotfix/HF2"
git checkout $branch
set +e
git flow hotfix finish --tagname "1.2.1" --message "Work item $branch completed."
set -e
resolve_and_commit
git flow hotfix finish "HF2" --tagname "1.2.1" --message "Work item $branch completed."
## ==== ==== ==== ====
t="t-22"
branch="bugfix/BF3"
git checkout $branch
git flow bugfix finish
## ==== ==== ==== ====
t="t-23"
branch="release/R3"
git checkout $branch
merge_and_resolve "master"
set +e
git flow release finish --tagname "1.3.0" --message "Work item $branch completed."
set -e
resolve_and_commit
git flow release finish "R3" --tagname "1.3.0" --message "Work item $branch completed."