canvas_update script: fix bug with missing gems/plugins and/or

vendor/plugins

When either gems/plugins or vendor/plugins doesn't exist in the repo,
the script would print an error as it tried to list the directory
contents through globbing.  This fixes that error.

Fixes CNVS-19519

Test Plan:
    - Create a new checkout with no vendor/plugins directory, or delete
      the existing one (not recommended)
    - Run the script and ensure it does not report an error with
      a missing vendor/plugins/*
    - Ensure the script completes without error

Change-Id: I4d49fc090d4abc21ac8e8005f4ed83c47b4e89c5
Reviewed-on: https://gerrit.instructure.com/50961
Reviewed-by: Cameron Sutter <csutter@instructure.com>
Product-Review: Cameron Sutter <csutter@instructure.com>
Tested-by: Jenkins
QA-Review: Benjamin Porter <bporter@instructure.com>
This commit is contained in:
Benjamin Porter 2015-03-24 20:17:40 -06:00
parent 3d180c1e7f
commit b8b8b65097
1 changed files with 16 additions and 10 deletions

View File

@ -38,20 +38,26 @@ function intro_message {
echo "-----------------------------" >>"$LOG"
}
function update_plugin {
(
cd "$1"
if is_git_dir; then
echo_console_and_log " Updating plugin $1 ..."
( git checkout master >>"$LOG" 2>&1 && \
git pull --rebase >>"$LOG" 2>&1 ) || \
( echo " failed to pull plugin (see $LOG)"; kill -INT $$ )
fi
)
}
function update_plugins {
# Loop through each plugin dir, and if it's a git repo, update it
# This needs to be done first so that db:migrate can pull in any plugin-
# precipitated changes to the database.
for PLUGIN in {gems,vendor}/plugins/*; do
(
cd "$PLUGIN"
if is_git_dir; then
echo_console_and_log " Updating plugin $PLUGIN ..."
( git checkout master >>"$LOG" 2>&1 && \
git pull --rebase >>"$LOG" 2>&1 ) || \
( echo " failed to pull plugin (see $LOG)"; kill -INT $$ )
fi
)
for dir in {gems,vendor}; do
if [ -d "$dir/plugins" ]; then
for plugin in $dir/plugins/*; do update_plugin "$plugin"; done
fi
done
}