Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Drush configuration for git repositories
<?php
/**
* @file
* Drush alias file for git repositories
* with predefined options for sql-dump command
*
* Place as etc/drush/aliases.drushrc.php
* within your git repository
*
* @see http://netzaffe.de/node/1608 for details about repository structure
* @see http://drupal.org/project/drush_sql_dump_hold for hold option
* @see etc/drush/git.drushrc.php for modifying structure-tables-key array
*/
exec('git rev-parse --git-dir 2> /dev/null', $output);
if (!empty($output)) {
$repo = $output[0];
$aliases['git'] = array(
'uri' => 'default',
'root' => realpath($repo . '/../drupal'),
'command-specific' => array (
'sql-dump' => array(
'result-file' => TRUE,
'result-file' => realpath($repo . '/../dumps/') . '/@DATABASE_@DATE.sql',
'gzip' => TRUE,
'structure-tables-key' => 'common',
// Do not use strict,
// suppress errors, if drush_dump_hold (hold option) is not available.
'strict' => FALSE,
// Additional hold option from https://drupal.org/project/drush_sql_dump_hold.
'hold' => 31,
// Always confirm purge with yes.
'yes' => TRUE,
),
),
);
}
<?php
/**
* @file
* example.drushrc.php for git repositories
*
* Tries to load git.drushrc.php as additional config
* and searches for aliases in specified $options['alias-path']
* if we are within a git repository.
*
* @see http://netzaffe.de/node/1608 for details about git repository structure.
*
* Rename this file to drushrc.php and optionally copy it to one of
* convenient places, or append the code below to the end of
* listed below locations in order of precedence:
*
* 1. Drupal site folder (e.g sites/{default|example.com}/drushrc.php).
* 2. Drupal installation root.
* 3. In any location, as specified by the --config (-c) option.
* 4. User's .drush folder (i.e. ~/.drush/drushrc.php).
* 5. System wide configuration folder (e.g. /etc/drush/drushrc.php).
* 6. Drush installation folder.
*
*/
exec('git rev-parse --git-dir 2> /dev/null', $output);
if (!empty($output)) {
$repo = $output[0];
$options['config'] = $repo . '/../etc/drush/git.drushrc.php';
$options['alias-path'] = $repo . '/../etc/drush';
}
<?php
/**
* @file
* Specifific drushrc.php for git repositories
*
* Place as etc/drush/git.drushrc.php
* within your git repository
*
* @see http://netzaffe.de/node/1608 for details about repository structure
*/
exec('git rev-parse --git-dir 2> /dev/null', $output);
if (!empty($output)) {
$repo = $output[0];
$options['r'] = realpath($repo . '/../drupal');
$options['l'] = 'default';
$options['structure-tables']['common'] = array(
'accesslog', 'cache', 'cache_block',
'cache_filter', 'cache_form', 'cache_menu',
'cache_page', 'cache_update', 'history',
'search_dataset', 'search_index', 'search_total',
'sessions', 'watchdog',
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment