Last active
October 10, 2015 22:48
-
-
Save chrisl8888/3762567 to your computer and use it in GitHub Desktop.
drush gl - Use drush to git pull files from the target. Usage `drush gl @mysite.dev`
This file contains hidden or 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 | |
/** | |
* Implementation of hook_drush_command(). | |
*/ | |
function gl_drush_command() { | |
$items['git-pull'] = array( | |
'aliases' => array( | |
'gl' | |
), | |
'bootstrap' => DRUSH_BOOTSTRAP_MAX, | |
'description' => 'Attempts to pull the repo for the remote server.', | |
); | |
return $items; | |
} | |
function drush_gl_git_pull(){ | |
$drupal_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT'); | |
if (empty($drupal_root)) { | |
return drush_user_abort('The Drupal root path cannot be found, please run this command in a higher Drupal bootstrap.'); | |
} | |
drush_shell_exec('cd ' . DRUPAL_ROOT); | |
drush_shell_exec('git status'); | |
$output = drush_shell_exec_output(); | |
foreach ($output as $msg) { | |
if (strpos($msg, 'Not a git repository') !== FALSE) { | |
return drush_user_abort('Aborting: The Drupal root path does not contain a valid .git repository.'); | |
} | |
if (strpos($msg, 'working directory clean')) { | |
drush_log('Git repository is currently clean.', 'status'); | |
} | |
} | |
drush_log('Attempting to pull the latest code...', 'status'); | |
drush_shell_exec_interactive('git pull'); | |
} |
This file contains hidden or 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 | |
cd $HOME/.drush | |
mkdir -p $HOME/.drush/inc && cd $HOME/.drush/inc | |
wget https://gist.github.com/chrisjlee/3762567/raw/0dd9f49dec5790690716a3a8fac250ad928f6a36/gl.drush.inc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
install: