Skip to content

Instantly share code, notes, and snippets.

@esolitos
Created August 2, 2017 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esolitos/14107ee719865765906407e1b73c0607 to your computer and use it in GitHub Desktop.
Save esolitos/14107ee719865765906407e1b73c0607 to your computer and use it in GitHub Desktop.
Automatically updates a list of modules, asks for confirmation, and commits code changes. (has to be run from DRUPAL_ROOT)
#!/bin/bash
DRUSH=$(which drush)
GIT=$(which git)
if [ -z $DRUSH -o -z $GIT ]; then
echo "Missing drush!"
exit -1
fi
required_updates="$(drush up -q -n --pipe 2>/dev/null)"
for mdl in $required_updates; do
mdl_path="$(drush pmi --fields=path --format=list $mdl)"
echo "#"
echo "# Upgrading module: $mdl"
echo "#"
$DRUSH up -y "$mdl"
echo "#"
echo "# Git status after upgrade: $mdl"
echo "#"
$GIT status "$mdl_path"
echo "#"
echo "# Please test the site and come back."
echo "#"
read -p "Is the site working fine? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1
fi
$GIT add "$mdl_path"
$GIT commit -m "Update module: $mdl"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment