Skip to content

Commit 60b7759

Browse files
committed
Don't use Bash arrays when we don't need to, for better support in older Bash versions.
1 parent b47fdc0 commit 60b7759

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

linux/move-migrations

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,16 @@ cd "$app_name/migrations"
2929

3030
# A command for finding migrations added in this branch
3131
added_migrations="git diff --name-only --diff-filter=A --relative $branch_name --"
32-
moved_files=()
32+
last_moved_file=''
3333

3434
# A function for finding the last migration file.
3535
find_last_migration() {
3636
local last_filename
3737
local last_file_found=0
3838

39-
if [ "${#moved_files[@]}" -gt 0 ]; then
40-
# We have already moved at least one file, so return the last one
41-
# we moved. We don't have to search for any more files.
42-
echo "${moved_files[-1]}"
39+
if [ "$last_moved_file" != '' ]; then
40+
# We have already moved a file before, so use that one.
41+
echo "$last_moved_file"
4342
return 0
4443
fi
4544

@@ -106,9 +105,8 @@ for filename in $($added_migrations .); do
106105
# Fix the dependencies.
107106
sed -i "${start_line},${end_line}s/('$app_name', '[^']\+')/('$app_name', '$end_migration_name')/" "$new_filename"
108107

109-
# Add this file to the array of moved files, so it will become the new
110-
# 'last' file.
111-
moved_files+=("$new_filename")
108+
# Use this moved file as the last moved file.
109+
last_moved_file="$new_filename"
112110
done
113111

114112
# Now add all of the changes.

0 commit comments

Comments
 (0)