Skip to content

Instantly share code, notes, and snippets.

@justin-endler
Created December 10, 2012 17:00
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 justin-endler/4251807 to your computer and use it in GitHub Desktop.
Save justin-endler/4251807 to your computer and use it in GitHub Desktop.
Sets up a local Drupal 7 branch review and attempts a merge with a forked-from repo.
#!/bin/bash
#
# Sets up a local Drupal 7 branch review and attempts a merge with a forked-from repo.
#
# @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."
echo -e "\nForked-from repo:"
read forked_from_repo
echo -e "\nReview Branch name:"
read review_branch_name
echo -e "\nReview Branch repo:"
read review_branch_repo
echo -e "\nParent directory:"
read parent_dir
# create database
# @todo add error handling to make sure mysql is running.
echo -e "\nCreate db..."
touch ~/create_review_db.mysql
dbname="review_$review_branch_name"
createdbstatement="CREATE DATABASE \`$dbname\`;"
echo "$createdbstatement" > ~/create_review_db.mysql
/Applications/MAMP/Library/bin/mysql -p -u root < ~/create_review_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 $dbname < $db_dump_path
# clone forkedFrom
echo -e "\nCloning $forked_from_repo develop branch..."
cd $parent_dir
git clone -b develop $forked_from_repo $review_branch_name
cd $review_branch_name
# merge in review branch
echo -e "\nMerging in review branch..."
git remote add reviewRepo $review_branch_repo
git fetch reviewRepo
git merge reviewRepo/$review_branch_name
# submodules
echo -e "\nGet submodules..."
git submodule init
git submodule update
# again in case of time out on first
git submodule update
# write database settings to settings.php
# $databases['default']['default'] = array(
# 'driver' => 'mysql',
# 'database' => $feature_branch_name,
# 'username' => 'root',
# 'password' => 'root',
# 'host' => 'localhost',
# 'prefix' => ''
# );
echo -e "\nWrite db config to settings.php..."
cd sites/default
touch settings.php
curl "$defaultsettings" > settings.php
echo "\$databases['default']['default'] = array('driver' => 'mysql','database' => '$dbname','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