@@ -137,11 +137,11 @@ if [[ ${#file[@]} -eq 0 ]];then
137
137
fi
138
138
139
139
if [[ -z " ${from} " ]]; then
140
- err " No 'from' version specified."
140
+ echo " No 'from' version specified." >&2
141
+ usage
141
142
fi
142
143
143
144
# TODO: compare steps in from_parts and to_parts.
144
- # This could be further automated to support bump levels (major/minor/build/SNAPSHOT)
145
145
version " ${from} " from_parts
146
146
147
147
if [[ -z " ${to} " ]]; then
@@ -189,17 +189,33 @@ d "Moving from=${from} to=${to}"
189
189
190
190
trap ' rm -f sedscript.sed' EXIT
191
191
192
- sed_cross () {
192
+ sed_cross () {
193
193
# Cross-platform sed invocation. OSX has no option to show a version number in sed.
194
194
local target=$1
195
195
sed --version > /dev/null 2>&1 && sed -e -i ' ' -f sedscript.sed " $target " || sed -i ' ' -E -f sedscript.sed " $target "
196
196
}
197
197
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.
202
205
echo " ERROR: Failed to update $filename to target version ${to} " >&2
203
206
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}
204
220
done
205
221
0 commit comments