Created
December 17, 2015 15:27
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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." |
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
For now, it only works if you are in the modules/themes directory (parent of the extension you are updating).
The script prompts you for drush alias, Jira (or other) ticket, and extension. If you are updating several extensions, then you can set environment variables (DRUSH_ALIAS and JIRA_TICKET) and skip those two prompts.
After calling
drush update-code
, the script prompts you for the new and old version numbers: you can copy and paste these from the drush output. The commit message is