Created
July 26, 2013 21:39
-
-
Save clifgriffin/6092443 to your computer and use it in GitHub Desktop.
Parse current branch name from Git repository and conditionally set WordPress database name.
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
<?php | |
$git_head = file('.git/HEAD', FILE_USE_INCLUDE_PATH); | |
$git_head = $git_head[0]; //get the string from the array | |
$git_head = explode("/", $git_head); //separate out by the "/" in the string | |
$branch_name = trim($git_head[2]); //get the one that is always the branch name | |
if($branch_name == "master") | |
{ | |
/** The name of the database for WordPress */ | |
define('DB_NAME', 'wordpress_local'); | |
} | |
else | |
{ | |
define('DB_NAME', 'wordpress_new'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment