You are here

git_deploy.drush.inc in Git Deploy 6

Same filename and directory in other branches
  1. 7 git_deploy.drush.inc

Drush integration for the git_deploy module.

File

git_deploy.drush.inc
View source
<?php

/**
 * @file
 * Drush integration for the git_deploy module.
 */

/**
 * Implements hook_drush_command().
 */
function git_deploy_drush_command() {
  $items['git-deploy-download'] = array(
    'description' => dt('Downloads the glip library from https://github.com/halstead/glip/.'),
    'arguments' => array(
      'path' => dt('Optional. A path to the download folder. If omitted, Drush will use sites/all/libraries/glip.'),
    ),
    'aliases' => array(
      'gdd',
    ),
  );
  return $items;
}

/**
 * Implements hook_drush_help().
 */
function git_deploy_drush_help($section) {
  switch ($section) {
    case 'drush:git_deploy-download':
      return dt('Downloads the glip library from https://github.com/halstead/glip/. Places it in the libraries directory. Skips download if library already present. This all happens automatically if you enable git_deploy using Drush.');
  }
}

/**
 * A command callback. Downloads the glip library using Git.
 */
function drush_git_deploy_download() {
  $args = func_get_args();
  if (isset($args[0])) {
    $path = $args[0];
  }
  else {
    if (module_exists('libraries')) {
      $path = libraries_get_path('glip');
    }
    else {
      $path = variable_get('git_deploy_glip_path', 'sites/all/libraries/glip');
    }
  }
  if (is_dir($path)) {
    drush_log('glip already present. No download required.', 'ok');
  }
  elseif (drush_shell_cd_and_exec(dirname($path), 'git clone https://github.com/halstead/glip.git && cd glip && git checkout 1.1')) {
    variable_set('git_deploy_glip_path', $path);
    drush_log(dt('glip has been cloned via Git to @path.', array(
      '@path' => $path,
    )), 'success');
  }
  else {
    drush_log(dt('Drush was unable to clone glip to @path.', array(
      '@path' => $path,
    )), 'error');
  }
}

/**
 * Implements drush_MODULE_post_COMMAND().
 */
function drush_git_deploy_post_pm_enable() {
  $modules = func_get_args();
  if (in_array('git_deploy', $modules)) {
    drush_git_deploy_download();
  }
}

Functions

Namesort descending Description
drush_git_deploy_download A command callback. Downloads the glip library using Git.
drush_git_deploy_post_pm_enable Implements drush_MODULE_post_COMMAND().
git_deploy_drush_command Implements hook_drush_command().
git_deploy_drush_help Implements hook_drush_help().