Skip to content

Instantly share code, notes, and snippets.

@benjifisher
Created December 17, 2015 15:27
Show Gist options
  • Save benjifisher/c99368864a7ea0a38c44 to your computer and use it in GitHub Desktop.
Save benjifisher/c99368864a7ea0a38c44 to your computer and use it in GitHub Desktop.
Update a Drupal extension (module or theme) and commit to git with this shell script.
#!/bin/bash
echo Update a Drupal extension and commit the result to git.
echo Warning: alpha version. Assumes you are in sites/all/modules/contrib or similar.
read -e -p 'Which extension? ' EXT
if [ -z "$DRUSH_ALIAS" ]; then
read -e -p 'Site alias (include "@"): ' ALIAS
else
ALIAS=$DRUSH_ALIAS
echo "Site alias: $ALIAS"
fi
if [ -z "$JIRA_TICKET" ]; then
read -e -p 'JIRA ticket: ' JIRA
else
JIRA=$JIRA_TICKET
echo "JIRA ticket: $JIRA"
fi
echo OK, I will update $EXT
echo drush $ALIAS -y pm-updatecode $EXT
drush $ALIAS -y pm-updatecode $EXT
read -e -p 'New version (include 7.x-): ' NEW
read -e -p 'Old version (include 7.x-): ' OLD
echo git add -A $EXT
git add -A $EXT
echo git commit -m\"$JIRA: Update $EXT to $NEW from $OLD.\"
git commit -m"$JIRA: Update $EXT to $NEW from $OLD."
@benjifisher
Copy link
Author

The drush pm-updatecode step seems to take a long time. This may be a problem for me because I am running Drupal on a vagrant VM. It may help to add the --cache flag, or it may help to run drush pm-updatestatus once to get all download information before updating the extensions one at a time. I will have to experiment the next time I use this. If all else fails, revert to drush pm-download.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment