git-release 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +150 -0
- data/Rakefile +1 -0
- data/bin/git-release +135 -0
- data/bin/git-release-deployed +140 -0
- data/git-release.gemspec +23 -0
- data/lib/git-release.rb +1 -0
- data/lib/git_release/version.rb +3 -0
- data/support/changelog-functions.sh +200 -0
- data/support/git-functions.sh +78 -0
- data/support/git-release-functions.sh +125 -0
- data/support/language-bash.sh +30 -0
- data/support/support-functions.sh +10 -0
- data/test/bin/run_all +7 -0
- data/test/integration/releaseable-deployed-test.sh +359 -0
- data/test/integration/releaseable-test.sh +409 -0
- data/test/support/roundup +310 -0
- data/test/test_helper.sh +95 -0
- data/test/unit/changelog-functions-test.sh +440 -0
- data/test/unit/git-functions-test.sh +215 -0
- data/test/unit/releaseable-test.sh +185 -0
- metadata +112 -0
@@ -0,0 +1,310 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# [r5]: roundup.5.html
|
3
|
+
# [r1t]: roundup-1-test.sh.html
|
4
|
+
# [r5t]: roundup-5-test.sh.html
|
5
|
+
|
6
|
+
#Direct copy of roundup so we can use it on Travis CI
|
7
|
+
#https://github.com/bmizerany/roundup
|
8
|
+
#
|
9
|
+
# _(c) 2010 Blake Mizerany - MIT License_
|
10
|
+
#
|
11
|
+
# Spray **roundup** on your shells to eliminate weeds and bugs. If your shells
|
12
|
+
# survive **roundup**'s deathly toxic properties, they are considered
|
13
|
+
# roundup-ready.
|
14
|
+
#
|
15
|
+
# **roundup** reads shell scripts to form test plans. Each
|
16
|
+
# test plan is sourced into a sandbox where each test is executed.
|
17
|
+
#
|
18
|
+
# See [roundup-1-test.sh.html][r1t] or [roundup-5-test.sh.html][r5t] for example
|
19
|
+
# test plans.
|
20
|
+
#
|
21
|
+
# __Install__
|
22
|
+
#
|
23
|
+
# git clone http://github.com/bmizerany/roundup.git
|
24
|
+
# cd roundup
|
25
|
+
# make
|
26
|
+
# sudo make install
|
27
|
+
# # Alternatively, copy `roundup` wherever you like.
|
28
|
+
#
|
29
|
+
# __NOTE__: Because test plans are sourced into roundup, roundup prefixes its
|
30
|
+
# variable and function names with `roundup_` to avoid name collisions. See
|
31
|
+
# "Sandbox Test Runs" below for more insight.
|
32
|
+
|
33
|
+
# Usage and Prerequisites
|
34
|
+
# -----------------------
|
35
|
+
|
36
|
+
# Exit if any following command exits with a non-zero status.
|
37
|
+
set -e
|
38
|
+
|
39
|
+
# The current version is set during `make version`. Do not modify this line in
|
40
|
+
# anyway unless you know what you're doing.
|
41
|
+
ROUNDUP_VERSION="0.0.5"
|
42
|
+
export ROUNDUP_VERSION
|
43
|
+
|
44
|
+
# Usage is defined in a specific comment syntax. It is `grep`ed out of this file
|
45
|
+
# when needed (i.e. The Tomayko Method). See
|
46
|
+
# [shocco](http://rtomayko.heroku.com/shocco) for more detail.
|
47
|
+
#/ usage: roundup [--help|-h] [--version|-v] [plan ...]
|
48
|
+
|
49
|
+
roundup_usage() {
|
50
|
+
grep '^#/' <"$0" | cut -c4-
|
51
|
+
}
|
52
|
+
|
53
|
+
while test "$#" -gt 0
|
54
|
+
do
|
55
|
+
case "$1" in
|
56
|
+
--help|-h)
|
57
|
+
roundup_usage
|
58
|
+
exit 0
|
59
|
+
;;
|
60
|
+
--version|-v)
|
61
|
+
echo "roundup version $ROUNDUP_VERSION"
|
62
|
+
exit 0
|
63
|
+
;;
|
64
|
+
--color)
|
65
|
+
color=always
|
66
|
+
shift
|
67
|
+
;;
|
68
|
+
-)
|
69
|
+
echo >&2 "roundup: unknown switch $1"
|
70
|
+
exit 1
|
71
|
+
;;
|
72
|
+
*)
|
73
|
+
break
|
74
|
+
;;
|
75
|
+
esac
|
76
|
+
done
|
77
|
+
|
78
|
+
# Consider all scripts with names matching `*-test.sh` the plans to run unless
|
79
|
+
# otherwise specified as arguments.
|
80
|
+
if [ "$#" -gt "0" ]
|
81
|
+
then
|
82
|
+
roundup_plans="$@"
|
83
|
+
else
|
84
|
+
roundup_plans="$(ls *-test.sh)"
|
85
|
+
fi
|
86
|
+
|
87
|
+
: ${color:="auto"}
|
88
|
+
|
89
|
+
# Create a temporary storage place for test output to be retrieved for display
|
90
|
+
# after failing tests.
|
91
|
+
roundup_tmp="$PWD/.roundup.$$"
|
92
|
+
mkdir -p "$roundup_tmp"
|
93
|
+
|
94
|
+
trap "rm -rf \"$roundup_tmp\"" EXIT INT
|
95
|
+
|
96
|
+
# __Tracing failures__
|
97
|
+
roundup_trace() {
|
98
|
+
# Delete the first two lines that represent roundups execution of the
|
99
|
+
# test function. They are useless to the user.
|
100
|
+
sed '1d' |
|
101
|
+
# Delete the last line which is the "set +x" of the error trap
|
102
|
+
sed '$d' |
|
103
|
+
# Replace the rc=$? of the error trap with an verbose string appended
|
104
|
+
# to the failing command trace line.
|
105
|
+
sed '$s/.*rc=/exit code /' |
|
106
|
+
# Trim the two left most `+` signs. They represent the depth at which
|
107
|
+
# roundup executed the function. They also, are useless and confusing.
|
108
|
+
sed 's/^++//' |
|
109
|
+
# Indent the output by 4 spaces to align under the test name in the
|
110
|
+
# summary.
|
111
|
+
sed 's/^/ /' |
|
112
|
+
# Highlight the last line in front of the exit code to bring notice to
|
113
|
+
# where the error occurred.
|
114
|
+
#
|
115
|
+
# The sed magic puts every line into the hold buffer first, then
|
116
|
+
# substitutes in the previous hold buffer content, prints that and starts
|
117
|
+
# with the next cycle. At the end the last line (in the hold buffer)
|
118
|
+
# is printed without substitution.
|
119
|
+
sed -n "x;1!{ \$s/\(.*\)/$mag\1$clr/; };1!p;\$x;\$p"
|
120
|
+
}
|
121
|
+
|
122
|
+
# __Other helpers__
|
123
|
+
|
124
|
+
# Track the test stats while outputting a real-time report. This takes input on
|
125
|
+
# **stdin**. Each input line must come in the format of:
|
126
|
+
#
|
127
|
+
# # The plan description to be displayed
|
128
|
+
# d <plan description>
|
129
|
+
#
|
130
|
+
# # A passing test
|
131
|
+
# p <test name>
|
132
|
+
#
|
133
|
+
# # A failed test
|
134
|
+
# f <test name>
|
135
|
+
roundup_summarize() {
|
136
|
+
set -e
|
137
|
+
|
138
|
+
# __Colors for output__
|
139
|
+
|
140
|
+
# Use colors if we are writing to a tty device.
|
141
|
+
if (test -t 1) || (test $color = always)
|
142
|
+
then
|
143
|
+
red=$(printf "\033[31m")
|
144
|
+
grn=$(printf "\033[32m")
|
145
|
+
mag=$(printf "\033[35m")
|
146
|
+
clr=$(printf "\033[m")
|
147
|
+
cols=$(tput cols)
|
148
|
+
fi
|
149
|
+
|
150
|
+
# Make these available to `roundup_trace`.
|
151
|
+
export red grn mag clr
|
152
|
+
|
153
|
+
ntests=0
|
154
|
+
passed=0
|
155
|
+
failed=0
|
156
|
+
|
157
|
+
: ${cols:=10}
|
158
|
+
|
159
|
+
while read status name
|
160
|
+
do
|
161
|
+
case $status in
|
162
|
+
p)
|
163
|
+
ntests=$(expr $ntests + 1)
|
164
|
+
passed=$(expr $passed + 1)
|
165
|
+
printf " %-48s " "$name:"
|
166
|
+
printf "$grn[PASS]$clr\n"
|
167
|
+
;;
|
168
|
+
f)
|
169
|
+
ntests=$(expr $ntests + 1)
|
170
|
+
failed=$(expr $failed + 1)
|
171
|
+
printf " %-48s " "$name:"
|
172
|
+
printf "$red[FAIL]$clr\n"
|
173
|
+
roundup_trace < "$roundup_tmp/$name"
|
174
|
+
;;
|
175
|
+
d)
|
176
|
+
printf "%s\n" "$name"
|
177
|
+
;;
|
178
|
+
esac
|
179
|
+
done
|
180
|
+
# __Test Summary__
|
181
|
+
#
|
182
|
+
# Display the summary now that all tests are finished.
|
183
|
+
yes = | head -n 57 | tr -d '\n'
|
184
|
+
printf "\n"
|
185
|
+
printf "Tests: %3d | " $ntests
|
186
|
+
printf "Passed: %3d | " $passed
|
187
|
+
printf "Failed: %3d" $failed
|
188
|
+
printf "\n"
|
189
|
+
|
190
|
+
# Exit with an error if any tests failed
|
191
|
+
test $failed -eq 0 || exit 2
|
192
|
+
}
|
193
|
+
|
194
|
+
# Sandbox Test Runs
|
195
|
+
# -----------------
|
196
|
+
|
197
|
+
# The above checks guarantee we have at least one test. We can now move through
|
198
|
+
# each specified test plan, determine its test plan, and administer each test
|
199
|
+
# listed in a isolated sandbox.
|
200
|
+
for roundup_p in $roundup_plans
|
201
|
+
do
|
202
|
+
# Create a sandbox, source the test plan, run the tests, then leave
|
203
|
+
# without a trace.
|
204
|
+
(
|
205
|
+
# Consider the description to be the `basename` of the plan minus the
|
206
|
+
# tailing -test.sh.
|
207
|
+
roundup_desc=$(basename "$roundup_p" -test.sh)
|
208
|
+
|
209
|
+
# Define functions for
|
210
|
+
# [roundup(5)][r5]
|
211
|
+
|
212
|
+
# A custom description is recommended, but optional. Use `describe` to
|
213
|
+
# set the description to something more meaningful.
|
214
|
+
# TODO: reimplement this.
|
215
|
+
describe() {
|
216
|
+
roundup_desc="$*"
|
217
|
+
}
|
218
|
+
|
219
|
+
# Provide default `before` and `after` functions that run only `:`, a
|
220
|
+
# no-op. They may or may not be redefined by the test plan.
|
221
|
+
before() { :; }
|
222
|
+
after() { :; }
|
223
|
+
|
224
|
+
# Seek test methods and aggregate their names, forming a test plan.
|
225
|
+
# This is done before populating the sandbox with tests to avoid odd
|
226
|
+
# conflicts.
|
227
|
+
|
228
|
+
# TODO: I want to do this with sed only. Please send a patch if you
|
229
|
+
# know a cleaner way.
|
230
|
+
roundup_plan=$(
|
231
|
+
grep "^it_.*()" $roundup_p |
|
232
|
+
sed "s/\(it_[a-zA-Z0-9_]*\).*$/\1/g"
|
233
|
+
)
|
234
|
+
|
235
|
+
# We have the test plan and are in our sandbox with [roundup(5)][r5]
|
236
|
+
# defined. Now we source the plan to bring its tests into scope.
|
237
|
+
. ./$roundup_p
|
238
|
+
|
239
|
+
# Output the description signal
|
240
|
+
printf "d %s" "$roundup_desc" | tr "\n" " "
|
241
|
+
printf "\n"
|
242
|
+
|
243
|
+
for roundup_test_name in $roundup_plan
|
244
|
+
do
|
245
|
+
# Any number of things are possible in `before`, `after`, and the
|
246
|
+
# test. Drop into an subshell to contain operations that may throw
|
247
|
+
# off roundup; such as `cd`.
|
248
|
+
(
|
249
|
+
# Output `before` trace to temporary file. If `before` runs cleanly,
|
250
|
+
# the trace will be overwritten by the actual test case below.
|
251
|
+
{
|
252
|
+
# redirect tracing output of `before` into file.
|
253
|
+
{
|
254
|
+
set -x
|
255
|
+
# If `before` wasn't redefined, then this is `:`.
|
256
|
+
before
|
257
|
+
} &>"$roundup_tmp/$roundup_test_name"
|
258
|
+
# disable tracing again. Its trace output goes to /dev/null.
|
259
|
+
set +x
|
260
|
+
} &>/dev/null
|
261
|
+
|
262
|
+
# exit subshell with return code of last failing command. This
|
263
|
+
# is needed to see the return code 253 on failed assumptions.
|
264
|
+
# But, only do this if the error handling is activated.
|
265
|
+
set -E
|
266
|
+
trap 'rc=$?; set +x; set -o | grep "errexit.*on" >/dev/null && exit $rc' ERR
|
267
|
+
|
268
|
+
# If `before` wasn't redefined, then this is `:`.
|
269
|
+
before
|
270
|
+
|
271
|
+
# Momentarily turn off auto-fail to give us access to the tests
|
272
|
+
# exit status in `$?` for capturing.
|
273
|
+
set +e
|
274
|
+
(
|
275
|
+
# Set `-xe` before the test in the subshell. We want the
|
276
|
+
# test to fail fast to allow for more accurate output of
|
277
|
+
# where things went wrong but not in _our_ process because a
|
278
|
+
# failed test should not immediately fail roundup. Each
|
279
|
+
# tests trace output is saved in temporary storage.
|
280
|
+
set -xe
|
281
|
+
$roundup_test_name
|
282
|
+
) >"$roundup_tmp/$roundup_test_name" 2>&1
|
283
|
+
|
284
|
+
# We need to capture the exit status before returning the `set
|
285
|
+
# -e` mode. Returning with `set -e` before we capture the exit
|
286
|
+
# status will result in `$?` being set with `set`'s status
|
287
|
+
# instead.
|
288
|
+
roundup_result=$?
|
289
|
+
|
290
|
+
# It's safe to return to normal operation.
|
291
|
+
set -e
|
292
|
+
|
293
|
+
# If `after` wasn't redefined, then this runs `:`.
|
294
|
+
after
|
295
|
+
|
296
|
+
# This is the final step of a test. Print its pass/fail signal
|
297
|
+
# and name.
|
298
|
+
if [ "$roundup_result" -ne 0 ]
|
299
|
+
then printf "f"
|
300
|
+
else printf "p"
|
301
|
+
fi
|
302
|
+
|
303
|
+
printf " $roundup_test_name\n"
|
304
|
+
)
|
305
|
+
done
|
306
|
+
)
|
307
|
+
done |
|
308
|
+
|
309
|
+
# All signals are piped to this for summary.
|
310
|
+
roundup_summarize
|
data/test/test_helper.sh
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
#!/bin/bash -e
|
2
|
+
|
3
|
+
#Script spec helpers
|
4
|
+
|
5
|
+
script_directory() {
|
6
|
+
"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
7
|
+
}
|
8
|
+
|
9
|
+
#Search argument 1 for substring in argument 2
|
10
|
+
search_substring() {
|
11
|
+
if echo "$1" | grep -q "$2"; then
|
12
|
+
echo 'found'
|
13
|
+
else
|
14
|
+
echo 'missing'
|
15
|
+
fi;
|
16
|
+
}
|
17
|
+
|
18
|
+
should_succeed() {
|
19
|
+
if [[ $? = 0 ]]; then
|
20
|
+
return 0
|
21
|
+
else
|
22
|
+
return 1
|
23
|
+
fi;
|
24
|
+
}
|
25
|
+
|
26
|
+
should_fail() {
|
27
|
+
! should_succeed
|
28
|
+
}
|
29
|
+
|
30
|
+
file_should_exist() {
|
31
|
+
if [[ -f $1 ]];
|
32
|
+
then
|
33
|
+
return 0;
|
34
|
+
else
|
35
|
+
return 1;
|
36
|
+
fi;
|
37
|
+
}
|
38
|
+
|
39
|
+
file_should_not_exist() {
|
40
|
+
! file_should_exist $1
|
41
|
+
}
|
42
|
+
|
43
|
+
enter_sandbox() {
|
44
|
+
__DIR__="$PWD"
|
45
|
+
rm -rf .sandbox
|
46
|
+
mkdir -p .sandbox
|
47
|
+
cd .sandbox
|
48
|
+
}
|
49
|
+
|
50
|
+
remove_sandbox() {
|
51
|
+
rm -rf .sandbox
|
52
|
+
}
|
53
|
+
|
54
|
+
generate_git_repo() {
|
55
|
+
enter_sandbox
|
56
|
+
git init
|
57
|
+
touch 'commit_1'
|
58
|
+
git add -A
|
59
|
+
git commit -am "Initial Commit"
|
60
|
+
}
|
61
|
+
|
62
|
+
generate_sandbox_tags() {
|
63
|
+
if [[ ! -f '.git' ]]; then
|
64
|
+
#Generate git repo & enter sandbox
|
65
|
+
generate_git_repo
|
66
|
+
fi;
|
67
|
+
|
68
|
+
#Optional arrays for sets of tags and commits
|
69
|
+
if [[ "$1" != '' ]]; then
|
70
|
+
declare -a tag_names=("${!1}")
|
71
|
+
else
|
72
|
+
local tag_names="$1"
|
73
|
+
fi;
|
74
|
+
if [[ "$2" != '' ]]; then
|
75
|
+
declare -a tag_commit_messages=("${!2}")
|
76
|
+
else
|
77
|
+
local tag_commit_messages="$2"
|
78
|
+
fi;
|
79
|
+
|
80
|
+
if [[ $tag_names = '' ]]; then
|
81
|
+
echo "Error - Please be specific on the tag names you want to generate";
|
82
|
+
exit 1;
|
83
|
+
fi;
|
84
|
+
for i in "${!tag_names[@]}"; do
|
85
|
+
touch "change${i}" &>/dev/null
|
86
|
+
git add -A &>/dev/null
|
87
|
+
local commit_message="${tag_commit_messages[$i]}"
|
88
|
+
if [[ "$commit_message" = '' ]]; then
|
89
|
+
#Use default commit message
|
90
|
+
commit_message="Change : ${i}";
|
91
|
+
fi;
|
92
|
+
git commit -m "$commit_message" &>/dev/null
|
93
|
+
git tag "${tag_names[$i]}" &>/dev/null
|
94
|
+
done;
|
95
|
+
}
|
@@ -0,0 +1,440 @@
|
|
1
|
+
#!/bin/bash -e
|
2
|
+
|
3
|
+
. ./test/test_helper.sh
|
4
|
+
. ./support/git-functions.sh
|
5
|
+
. ./support/changelog-functions.sh
|
6
|
+
|
7
|
+
describe "git-release - unit - changelog"
|
8
|
+
|
9
|
+
after() {
|
10
|
+
if [[ $MAINTAIN_SANDBOX != true ]]; then
|
11
|
+
remove_sandbox
|
12
|
+
fi;
|
13
|
+
}
|
14
|
+
|
15
|
+
|
16
|
+
#get_changelog_text_for_commits
|
17
|
+
|
18
|
+
it_uses_get_changelog_text_for_commits_to_return_titles_by_default() {
|
19
|
+
local tags=(
|
20
|
+
'random_tag_1'
|
21
|
+
'release/v1.0.5'
|
22
|
+
'random_tag_2'
|
23
|
+
'release/v1.0.6'
|
24
|
+
)
|
25
|
+
|
26
|
+
local commit_message_1="Release 1.0.6"
|
27
|
+
local commit_message_2="Random Release 2"
|
28
|
+
local commit_message_3="Older Release 1.0.5"
|
29
|
+
|
30
|
+
local commit_messages=(
|
31
|
+
"Random Release numero uno"
|
32
|
+
"$commit_message_3"
|
33
|
+
"$commit_message_2"
|
34
|
+
"$commit_message_1"
|
35
|
+
)
|
36
|
+
generate_sandbox_tags tags[@] commit_messages[@]
|
37
|
+
|
38
|
+
local commit_shas=$(get_commits_between_points "release/v1.0.5" "release/v1.0.6")
|
39
|
+
|
40
|
+
output=$(get_changelog_text_for_commits "$commit_shas")
|
41
|
+
|
42
|
+
test "$output" = "${commit_message_1}
|
43
|
+
${commit_message_2}
|
44
|
+
${commit_message_3}"
|
45
|
+
}
|
46
|
+
|
47
|
+
it_uses_get_changelog_text_for_commits_to_return_titles_with_a_custom_format() {
|
48
|
+
local tags=(
|
49
|
+
'random_tag_1'
|
50
|
+
'release/v1.0.5'
|
51
|
+
'random_tag_2'
|
52
|
+
'release/v1.0.6'
|
53
|
+
)
|
54
|
+
|
55
|
+
local commit_message_1="Release 1.0.6"
|
56
|
+
local commit_message_2="Random Release 2"
|
57
|
+
local commit_message_3="Older Release 1.0.5"
|
58
|
+
|
59
|
+
local commit_messages=(
|
60
|
+
"Random Release numero uno"
|
61
|
+
"$commit_message_3"
|
62
|
+
"$commit_message_2"
|
63
|
+
"$commit_message_1"
|
64
|
+
)
|
65
|
+
generate_sandbox_tags tags[@] commit_messages[@]
|
66
|
+
|
67
|
+
local commit_shas=$(get_commits_between_points "release/v1.0.5" "release/v1.0.6")
|
68
|
+
local sha_array=($commit_shas)
|
69
|
+
|
70
|
+
output=$(get_changelog_text_for_commits "--format=%H--%s" "$commit_shas")
|
71
|
+
|
72
|
+
test "$output" = "${sha_array[0]}--${commit_message_1}
|
73
|
+
${sha_array[1]}--${commit_message_2}
|
74
|
+
${sha_array[2]}--${commit_message_3}"
|
75
|
+
}
|
76
|
+
|
77
|
+
it_uses_get_changelog_text_for_commits_to_return_titles_grouped_by_tags() {
|
78
|
+
local tags=(
|
79
|
+
"releases/v0.0.3"
|
80
|
+
"releases/v0.0.4"
|
81
|
+
"releases/v0.1.4"
|
82
|
+
"releases/v1.1.4"
|
83
|
+
"releases/v1.1.5"
|
84
|
+
"releases/v1.1.6"
|
85
|
+
)
|
86
|
+
local commit_messages=(
|
87
|
+
"Start of the project"
|
88
|
+
"[bugs]Argh, I fixed a bug here"
|
89
|
+
"[feature] OMG. I had time to write something of use"
|
90
|
+
"[features]Its so exciting writing useful things!!"
|
91
|
+
"[bug] What comes up, must come down"
|
92
|
+
"Some random tweak fix"
|
93
|
+
)
|
94
|
+
generate_sandbox_tags tags[@] commit_messages[@]
|
95
|
+
local commit_shas=$(get_commits_between_points "${tags[0]}" "${tags[5]}")
|
96
|
+
|
97
|
+
output=$(get_changelog_text_for_commits "$commit_shas")
|
98
|
+
|
99
|
+
local sha_array=($commit_shas)
|
100
|
+
test "$output" = "Features:
|
101
|
+
Its so exciting writing useful things!!
|
102
|
+
OMG. I had time to write something of use
|
103
|
+
|
104
|
+
Bugs:
|
105
|
+
What comes up, must come down
|
106
|
+
Argh, I fixed a bug here
|
107
|
+
|
108
|
+
Some random tweak fix
|
109
|
+
Start of the project"
|
110
|
+
}
|
111
|
+
|
112
|
+
it_uses_get_changelog_text_for_commits_to_return_titles_grouped_by_tags_case_insensitive() {
|
113
|
+
local tags=(
|
114
|
+
"releases/v0.0.3"
|
115
|
+
"releases/v1.1.5"
|
116
|
+
"releases/v1.1.6"
|
117
|
+
)
|
118
|
+
local commit_messages=(
|
119
|
+
"[Bug] Start of the project"
|
120
|
+
"[BUGS] Argh, I fixed a bug here"
|
121
|
+
"[fEaTuRes] OMG. I had time to write something of use"
|
122
|
+
)
|
123
|
+
generate_sandbox_tags tags[@] commit_messages[@]
|
124
|
+
local commit_shas=$(get_commits_between_points "${tags[0]}" "${tags[2]}")
|
125
|
+
|
126
|
+
output=$(get_changelog_text_for_commits "$commit_shas")
|
127
|
+
|
128
|
+
test "$output" = "Features:
|
129
|
+
OMG. I had time to write something of use
|
130
|
+
|
131
|
+
Bugs:
|
132
|
+
Argh, I fixed a bug here
|
133
|
+
Start of the project"
|
134
|
+
}
|
135
|
+
|
136
|
+
it_uses_get_changelog_text_for_commits_to_return_titles_grouped_by_tags_with_multiple_brackets() {
|
137
|
+
local tags=(
|
138
|
+
"releases/v0.0.3"
|
139
|
+
"releases/v1.1.6"
|
140
|
+
)
|
141
|
+
local commit_messages=(
|
142
|
+
"[BUGS] [QC Some Reference][More Custom References] Fixed the tagged bugs"
|
143
|
+
"[fEaTuRes][Additonal Tag one] Another referenced feature"
|
144
|
+
)
|
145
|
+
generate_sandbox_tags tags[@] commit_messages[@]
|
146
|
+
local commit_shas=$(get_commits_between_points "${tags[0]}" "${tags[1]}")
|
147
|
+
|
148
|
+
output=$(get_changelog_text_for_commits "$commit_shas")
|
149
|
+
|
150
|
+
test "$output" = "Features:
|
151
|
+
[Additonal Tag one] Another referenced feature
|
152
|
+
|
153
|
+
Bugs:
|
154
|
+
[QC Some Reference][More Custom References] Fixed the tagged bugs"
|
155
|
+
}
|
156
|
+
|
157
|
+
#generate_changelog_content
|
158
|
+
|
159
|
+
it_uses_generate_changelog_content_to_exit_with_errors_without_release_name() {
|
160
|
+
generate_git_repo
|
161
|
+
|
162
|
+
should_fail $(generate_changelog_content)
|
163
|
+
should_fail $(generate_changelog_content '')
|
164
|
+
}
|
165
|
+
|
166
|
+
it_uses_generate_changelog_content_to_exit_with_errors_with_invalid_commit_filter() {
|
167
|
+
generate_git_repo
|
168
|
+
|
169
|
+
should_fail $(generate_changelog_content 'AnyOldReleaseName')
|
170
|
+
should_fail $(generate_changelog_content 'AnyOldReleaseName' '')
|
171
|
+
should_fail $(generate_changelog_content 'AnyOldReleaseName' ':unknown')
|
172
|
+
should_fail $(generate_changelog_content 'AnyOldReleaseName' ':anything')
|
173
|
+
|
174
|
+
should_succeed $(generate_changelog_content 'AnyOldReleaseName' ':all_commits')
|
175
|
+
should_succeed $(generate_changelog_content 'AnyOldReleaseName' ':pulls_only')
|
176
|
+
}
|
177
|
+
|
178
|
+
it_uses_generate_changelog_content_to_succeed_without_a_startpoint() {
|
179
|
+
generate_git_repo
|
180
|
+
|
181
|
+
should_succeed $(generate_changelog_content 'v0.0.5' ':all_commits' '' 'releases/end/v02.34')
|
182
|
+
}
|
183
|
+
|
184
|
+
it_uses_generate_changelog_content_to_succeed_without_an_endpoint() {
|
185
|
+
generate_git_repo
|
186
|
+
|
187
|
+
should_succeed $(generate_changelog_content 'v0.0.5' ':all_commits' 'releases/v1.0.45')
|
188
|
+
}
|
189
|
+
|
190
|
+
it_uses_generate_changelog_content_to_generate_with_all_commit_messages(){
|
191
|
+
local tags=(
|
192
|
+
'random_tag_1'
|
193
|
+
'release/v1.0.5'
|
194
|
+
'random_tag_2'
|
195
|
+
'release/v1.0.6'
|
196
|
+
)
|
197
|
+
local commit_messages=(
|
198
|
+
'Message For Random Tag 1'
|
199
|
+
'[Any Old] Message for 1.0.5'
|
200
|
+
'Lots of changes in this commit for random tag 2'
|
201
|
+
'latest release to 1.0.6'
|
202
|
+
)
|
203
|
+
|
204
|
+
generate_sandbox_tags tags[@] commit_messages[@]
|
205
|
+
|
206
|
+
local custom_release_name="v1.0.7"
|
207
|
+
local output=$(generate_changelog_content "$custom_release_name" ':all_commits')
|
208
|
+
|
209
|
+
test "$output" = "$(changelog_divider)
|
210
|
+
|| Release: ${custom_release_name}
|
211
|
+
|| Released on $(get_current_release_date)
|
212
|
+
$(changelog_divider)
|
213
|
+
${commit_messages[3]}
|
214
|
+
${commit_messages[2]}
|
215
|
+
${commit_messages[1]}
|
216
|
+
${commit_messages[0]}
|
217
|
+
$(get_commit_message_for_first_commit)
|
218
|
+
$(changelog_divider)"
|
219
|
+
}
|
220
|
+
|
221
|
+
it_uses_generate_changelog_content_to_generate_with_commit_messages_for_a_range(){
|
222
|
+
local tags=(
|
223
|
+
'random_tag_1'
|
224
|
+
'release/v1.0.5'
|
225
|
+
'random_tag_2'
|
226
|
+
'release/v1.0.6'
|
227
|
+
)
|
228
|
+
local commit_messages=(
|
229
|
+
'Message For Random Tag 1'
|
230
|
+
'[Any Old] Message for 1.0.5'
|
231
|
+
'Lots of changes in this commit for random tag 2'
|
232
|
+
'latest release to 1.0.6'
|
233
|
+
)
|
234
|
+
|
235
|
+
generate_sandbox_tags tags[@] commit_messages[@]
|
236
|
+
|
237
|
+
local custom_release_name="v1.0.7"
|
238
|
+
local output=$(generate_changelog_content "$custom_release_name" ':all_commits' 'release/v1.0.5' 'random_tag_2')
|
239
|
+
|
240
|
+
test "$output" = "$(changelog_divider)
|
241
|
+
|| Release: ${custom_release_name}
|
242
|
+
|| Released on $(get_current_release_date)
|
243
|
+
$(changelog_divider)
|
244
|
+
${commit_messages[2]}
|
245
|
+
${commit_messages[1]}
|
246
|
+
$(changelog_divider)"
|
247
|
+
}
|
248
|
+
|
249
|
+
it_uses_generate_changelog_content_to_generate_scoped_to_only_pull_requests(){
|
250
|
+
local tags=(
|
251
|
+
'tag_with_pulls_1'
|
252
|
+
'tag_witout_pull'
|
253
|
+
'tag_with_pulls_2'
|
254
|
+
'another_tag_without'
|
255
|
+
'tag_with_pulls_3'
|
256
|
+
'tag_with_pulls_4'
|
257
|
+
)
|
258
|
+
local commit_messages=(
|
259
|
+
"Merge pull request #705 from Ferocia/bug/limit-payment-description-length
|
260
|
+
|
261
|
+
[BUG] Pay anyone from the accounts screen"
|
262
|
+
" This commit is not a pull request and should be ignored"
|
263
|
+
"Merge pull request #722 from Ferocia/feature/running-balance-field (Anthony Langhorne, 18 hours ago)
|
264
|
+
|
265
|
+
[Features] This is a pull request merging a feature across multiple
|
266
|
+
lines and continuing"
|
267
|
+
" Yet another commit,that isn't a pull request"
|
268
|
+
"Merge pull request #714 from Ferocia/fix-customer-login
|
269
|
+
|
270
|
+
Fixing the customer login but no tag displayed."
|
271
|
+
"Merge pull request #685 from Ferocia/bug/modal-new-payee
|
272
|
+
|
273
|
+
[Security] Commit fixing the modal with security flaw"
|
274
|
+
)
|
275
|
+
|
276
|
+
generate_sandbox_tags tags[@] commit_messages[@]
|
277
|
+
|
278
|
+
local custom_release_name="v2.0.5"
|
279
|
+
local output=$(generate_changelog_content "$custom_release_name" ':pulls_only')
|
280
|
+
|
281
|
+
test "$output" = "$(changelog_divider)
|
282
|
+
|| Release: ${custom_release_name}
|
283
|
+
|| Released on $(get_current_release_date)
|
284
|
+
$(changelog_divider)
|
285
|
+
Features:
|
286
|
+
This is a pull request merging a feature across multiple
|
287
|
+
lines and continuing
|
288
|
+
|
289
|
+
Security:
|
290
|
+
Commit fixing the modal with security flaw
|
291
|
+
|
292
|
+
Bugs:
|
293
|
+
Pay anyone from the accounts screen
|
294
|
+
|
295
|
+
Fixing the customer login but no tag displayed.
|
296
|
+
$(changelog_divider)"
|
297
|
+
}
|
298
|
+
|
299
|
+
#generate_version_file
|
300
|
+
|
301
|
+
it_uses_generate_version_file_to_fail_with_no_version_number_passed() {
|
302
|
+
should_fail $(generate_version_file)
|
303
|
+
}
|
304
|
+
|
305
|
+
it_uses_generate_version_file_to_create_a_version_file() {
|
306
|
+
enter_sandbox
|
307
|
+
|
308
|
+
file_should_not_exist "VERSION"
|
309
|
+
|
310
|
+
generate_version_file 'v12.03.23'
|
311
|
+
|
312
|
+
file_should_exist "VERSION"
|
313
|
+
|
314
|
+
test "$(cat VERSION)" = "v12.03.23"
|
315
|
+
}
|
316
|
+
|
317
|
+
it_uses_generate_version_file_to_create_a_custom_version_file() {
|
318
|
+
enter_sandbox
|
319
|
+
|
320
|
+
file_should_not_exist "CUSTOM_VERSION"
|
321
|
+
|
322
|
+
generate_version_file 'v12.03.23' 'CUSTOM_VERSION'
|
323
|
+
|
324
|
+
file_should_exist "CUSTOM_VERSION"
|
325
|
+
|
326
|
+
test "`cat CUSTOM_VERSION`" = "v12.03.23"
|
327
|
+
}
|
328
|
+
|
329
|
+
it_uses_generate_version_file_to_replace_any_existing_version_file() {
|
330
|
+
enter_sandbox
|
331
|
+
|
332
|
+
file_should_not_exist "VERSION"
|
333
|
+
|
334
|
+
generate_version_file 'v12.03.23'
|
335
|
+
|
336
|
+
file_should_exist "VERSION"
|
337
|
+
|
338
|
+
test "`cat VERSION`" = "v12.03.23"
|
339
|
+
|
340
|
+
generate_version_file 'v14.05.25'
|
341
|
+
|
342
|
+
test "`cat VERSION`" = "v14.05.25"
|
343
|
+
}
|
344
|
+
|
345
|
+
#generate_changelog_file
|
346
|
+
|
347
|
+
it_uses_generate_changelog_file_to_fail_with_content_passed_or_strategy() {
|
348
|
+
enter_sandbox
|
349
|
+
|
350
|
+
should_fail $(generate_changelog_file)
|
351
|
+
should_fail $(generate_changelog_file 'some content')
|
352
|
+
should_fail $(generate_changelog_file 'some content' '')
|
353
|
+
|
354
|
+
should_succeed $(generate_changelog_file 'some content' ':overwrite')
|
355
|
+
}
|
356
|
+
|
357
|
+
it_uses_generate_changelog_file_to_fail_with_invalid_strategy() {
|
358
|
+
enter_sandbox
|
359
|
+
|
360
|
+
should_fail $(generate_changelog_file 'some content' '')
|
361
|
+
should_fail $(generate_changelog_file 'some content' ':anything')
|
362
|
+
should_fail $(generate_changelog_file 'some content' ':unknown')
|
363
|
+
|
364
|
+
|
365
|
+
should_succeed $(generate_changelog_file 'some content' ':overwrite')
|
366
|
+
should_succeed $(generate_changelog_file 'some content' ':append')
|
367
|
+
}
|
368
|
+
|
369
|
+
it_uses_generate_changelog_file_file_to_create_a_changelog_file() {
|
370
|
+
enter_sandbox
|
371
|
+
|
372
|
+
file_should_not_exist "CHANGELOG"
|
373
|
+
|
374
|
+
local content="
|
375
|
+
My Content
|
376
|
+
Is Here Across Multiple Lines
|
377
|
+
"
|
378
|
+
local output=$(generate_changelog_file "$content" ':overwrite')
|
379
|
+
|
380
|
+
file_should_exist "CHANGELOG"
|
381
|
+
|
382
|
+
test "$(cat CHANGELOG)" = "$content
|
383
|
+
$(changelog_footer)"
|
384
|
+
}
|
385
|
+
|
386
|
+
it_uses_generate_changelog_file_file_to_create_a_custom_version_file() {
|
387
|
+
enter_sandbox
|
388
|
+
|
389
|
+
file_should_not_exist "CHANGELOG"
|
390
|
+
file_should_not_exist "CUSTOM_CHANGELOG"
|
391
|
+
|
392
|
+
local content="
|
393
|
+
My Content
|
394
|
+
Is Here Across Multiple Lines
|
395
|
+
"
|
396
|
+
output=$(generate_changelog_file "$content" ':overwrite' 'CUSTOM_CHANGELOG')
|
397
|
+
|
398
|
+
file_should_not_exist "CHANGELOG"
|
399
|
+
file_should_exist "CUSTOM_CHANGELOG"
|
400
|
+
|
401
|
+
test "`cat CUSTOM_CHANGELOG`" = "$content
|
402
|
+
$(changelog_footer)"
|
403
|
+
}
|
404
|
+
|
405
|
+
it_uses_generate_changelog_file_to_replace_any_existing_file_with_overwrite_strategy() {
|
406
|
+
enter_sandbox
|
407
|
+
|
408
|
+
file_should_not_exist "CHANGELOG"
|
409
|
+
|
410
|
+
output=$(generate_changelog_file 'Original Content' ':overwrite')
|
411
|
+
|
412
|
+
file_should_exist "CHANGELOG"
|
413
|
+
|
414
|
+
test "`cat CHANGELOG`" = "Original Content
|
415
|
+
$(changelog_footer)"
|
416
|
+
|
417
|
+
generate_changelog_file 'Updated Content' ':overwrite'
|
418
|
+
|
419
|
+
test "`cat CHANGELOG`" = "Updated Content
|
420
|
+
$(changelog_footer)"
|
421
|
+
}
|
422
|
+
|
423
|
+
it_uses_generate_changelog_file_to_append_to_any_existing_file_with_append_strategy() {
|
424
|
+
enter_sandbox
|
425
|
+
|
426
|
+
file_should_not_exist "CHANGELOG"
|
427
|
+
|
428
|
+
generate_changelog_file 'Original Content' ':append'
|
429
|
+
|
430
|
+
file_should_exist "CHANGELOG"
|
431
|
+
|
432
|
+
test "`cat CHANGELOG`" = "Original Content
|
433
|
+
$(changelog_footer)"
|
434
|
+
|
435
|
+
generate_changelog_file 'Updated Content' ':append'
|
436
|
+
|
437
|
+
test "`cat CHANGELOG`" = "Updated Content
|
438
|
+
Original Content
|
439
|
+
$(changelog_footer)"
|
440
|
+
}
|