Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit 7f0813c

Browse files
committed
bump.sh will now display error if file contents are unchanged
1 parent f717e90 commit 7f0813c

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

bin/utils/release/bump.sh

+23-7
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ if [[ ${#file[@]} -eq 0 ]];then
137137
fi
138138

139139
if [[ -z "${from}" ]]; then
140-
err "No 'from' version specified."
140+
echo "No 'from' version specified." >&2
141+
usage
141142
fi
142143

143144
# TODO: compare steps in from_parts and to_parts.
144-
# This could be further automated to support bump levels (major/minor/build/SNAPSHOT)
145145
version "${from}" from_parts
146146

147147
if [[ -z "${to}" ]]; then
@@ -189,17 +189,33 @@ d "Moving from=${from} to=${to}"
189189

190190
trap 'rm -f sedscript.sed' EXIT
191191

192-
sed_cross () {
192+
sed_cross() {
193193
# Cross-platform sed invocation. OSX has no option to show a version number in sed.
194194
local target=$1
195195
sed --version >/dev/null 2>&1 && sed -e -i '' -f sedscript.sed "$target" || sed -i '' -E -f sedscript.sed "$target"
196196
}
197197

198-
for filename in "${file[@]}"; do
199-
if sed_cross ${filename}; then
200-
echo "Updated $filename successfully!"
201-
else
198+
update_file() {
199+
local filename=$1
200+
local error_message="ERROR: Failed to update $filename to target version ${to}"
201+
local original_hash=$(ruby -r digest -e "p Digest::SHA2.file(\"$filename\").hexdigest")
202+
local final_hash=""
203+
if ! sed_cross ${filename}; then
204+
# occurs if, for example, the file doesn't exist.
202205
echo "ERROR: Failed to update $filename to target version ${to}" >&2
203206
fi
207+
208+
local final_hash=$(ruby -r digest -e "p Digest::SHA2.file(\"$filename\").hexdigest")
209+
210+
if [[ "${original_hash}" = "${final_hash}" ]]; then
211+
# occurs if, for example, the file doesn't have expected marker tags for replacement
212+
echo "ERROR: $filename was not modified." >&2
213+
else
214+
echo "Updated $filename successfully!"
215+
fi
216+
}
217+
218+
for filename in "${file[@]}"; do
219+
update_file ${filename}
204220
done
205221

0 commit comments

Comments
 (0)