Created
December 10, 2012 14:46
-
-
Save justin-endler/4250948 to your computer and use it in GitHub Desktop.
Sets up Drupal 7 local and remote feature branch.
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 | |
# | |
# Sets up a local Drupal 7 environment for working on a feature branch. | |
# | |
# @author Justin Endler | |
# | |
defaultsettings="http://drupalcode.org/project/drupal.git/blob_plain/HEAD:/sites/default/default.settings.php" | |
echo -e "\nThis script is D7-specific." | |
# get info | |
echo -e "\nFeature Branch name:" | |
read feature_branch_name | |
echo -e "\nParent Directory:" | |
read parent_dir | |
echo -e "\nMy Fork:" | |
read my_fork | |
echo -e "\nForked-from Repo:" | |
read forked_from_repo | |
# create database | |
# @todo add error handling for when mysql is not running | |
echo -e "\nCreate db..." | |
touch ~/create_feature_db.mysql | |
createdbstatement="CREATE DATABASE \`$feature_branch_name\`;" | |
echo "$createdbstatement" > ~/create_feature_db.mysql | |
/Applications/MAMP/Library/bin/mysql -p -u root < ~/create_feature_db.mysql | |
# import database | |
echo -e "\nImport db..." | |
echo -e "\nEnter the mysql dump backup path:" | |
read db_dump_path | |
/Applications/MAMP/Library/bin/mysql -p -u root $feature_branch_name < $db_dump_path | |
# get the repo code | |
echo -e "\nCloning develop branch..." | |
cd $parent_dir | |
git clone -b develop $my_fork $feature_branch_name | |
cd $feature_branch_name | |
echo -e "\nGet submodules..." | |
git submodule init | |
git submodule update | |
# again in case of time out on first | |
git submodule update | |
# merge with forked-from | |
echo -e "\nAttempting merge with forked-from repo..." | |
git remote add forkedFrom $forked_from_repo | |
git fetch forkedFrom | |
git merge forkedFrom/develop | |
# update remote develop | |
git push origin develop | |
# create local branch | |
echo -e "\nCreate local branch..." | |
git checkout -b $feature_branch_name | |
# create remote branch | |
echo -e "\nCreate remote branch..." | |
git push origin $feature_branch_name | |
# write database settings to settings.php | |
# $databases['default']['default'] = array( | |
# 'driver' => 'mysql', | |
# 'database' => $feature_branch_name, | |
# 'username' => 'root', | |
# 'password' => 'root', | |
# 'host' => 'localhost', | |
# 'prefix' => '' | |
# ); | |
echo "\nWrite db config to settings.php..." | |
cd sites/default | |
touch settings.php | |
curl "$defaultsettings" > settings.php | |
echo "\$databases['default']['default'] = array('driver' => 'mysql','database' => '$feature_branch_name','username' => 'root','password' => 'root','host' => 'localhost','prefix' => '');" >> settings.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment