Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeker committed Nov 3, 2015
2 parents 3269328 + e68ee46 commit 0878e99
Show file tree
Hide file tree
Showing 44 changed files with 499 additions and 286 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
tests/phpunit.xml
vendor
/lib/Console_Table-1.1.3/
box.phar
drush.phar
#A library from Drush6 and prior that can come back when you switch branches.
*youngj-httpserver*
#The mkdocs output directory.
Expand Down
29 changes: 29 additions & 0 deletions box.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"alias": "drush.phar",
"chmod": "0755",
"compactors": [
"Herrera\\Box\\Compactor\\Json",
"Herrera\\Box\\Compactor\\Php"
],
"directories": ["commands", "docs", "examples", "includes", "lib", "misc"],
"files": ["drush.api.php", "drush.bat", "drush.complete.sh", "drush.info", "drush.launcher", "drush.php", "drush_logo-black.png", "README.md"],
"finder": [
{
"name": "*.php",
"exclude": [
"phing",
"test",
"tests",
"Test",
"Tests",
"Tester"
],
"in": "vendor"
}
],
"git-commit": "git-commit",
"git-version": "git-version",
"output": "drush.phar",
"main": "drush",
"stub": true
}
4 changes: 2 additions & 2 deletions commands/core/archive.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function archive_drush_command() {
'description' => 'Describe the archive contents.',
'tags' => 'Add tags to the archive manifest. Delimit multiple by commas.',
'destination' => 'The full path and filename in which the archive should be stored. If omitted, it will be saved to the drush-backups directory and a filename will be generated.',
'overwrite' => 'Do not fail if the destination file exists; overwrite it instead.',
'overwrite' => 'Do not fail if the destination file exists; overwrite it instead. Default is --no-overwrite.',
'generator' => 'The generator name to store in the MANIFEST file. The default is "Drush archive-dump".',
'generatorversion' => 'The generator version number to store in the MANIFEST file. The default is ' . DRUSH_VERSION . '.',
'pipe' => 'Only print the destination of the archive. Useful for scripts that don\'t pass --destination.',
Expand Down Expand Up @@ -50,7 +50,7 @@ function archive_drush_command() {
),
'db-su' => 'Account to use when creating the new database. Optional.',
'db-su-pw' => 'Password for the "db-su" account. Optional.',
'overwrite' => 'Allow drush to overwrite any files in the destination.',
'overwrite' => 'Allow drush to overwrite any files in the destination. Default is --no-overwrite.',
'tar-options' => 'Options passed thru to the tar command.',
),
'examples' => array(
Expand Down
2 changes: 1 addition & 1 deletion commands/core/browse.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function browse_drush_command() {
'path' => 'Path to open. If omitted, the site front page will be opened.',
),
'options' => array(
'browser' => 'Specify a particular browser (defaults to operating system default). Set to 0 to suppress opening a browser.',
'browser' => 'Specify a particular browser (defaults to operating system default). Use --no-brower to suppress opening a browser.',
'redirect-port' => 'The port that the web server is redirected to (e.g. when running within a Vagrant environment)',
),
'examples' => array(
Expand Down
109 changes: 102 additions & 7 deletions commands/core/config.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ function config_drush_command() {
'description' => 'Make commit on provided working branch. Ignored if used without --commit or --push.',
'example-value' => 'branchname',
),
'destination' => 'An arbitrary directory that should receive the exported files. An alternative to label argument',
'destination' => 'An arbitrary directory that should receive the exported files. An alternative to label argument.',
'skip-modules' => 'A list of modules to ignore during export (e.g. to avoid listing dev-only modules in exported configuration).',
),
'examples' => array(
'drush config-export --skip-modules=devel' => 'Export configuration; do not include the devel module in the exported configuration, regardless of whether or not it is enabled in the site.',
'drush config-export --destination' => 'Export configuration; Save files in a backup directory named config-export.',
),
);

Expand Down Expand Up @@ -174,6 +175,29 @@ function config_drush_command() {
),
);

$items['config-pull'] = array(
'description' => 'Export and transfer config from one environment to another.',
// 'core' => array('8+'), Operates on remote sites so not possible to declare this locally.
'drush dependencies' => array('config', 'core'), // core-rsync, core-execute.
'bootstrap' => DRUSH_BOOTSTRAP_NONE,
'aliases' => array('cpull'),
'arguments' => array(
'source' => 'A site-alias or the name of a subdirectory within /sites whose config you want to copy from.',
'target' => 'A site-alias or the name of a subdirectory within /sites whose config you want to replace.',
),
'required-arguments' => TRUE,
'allow-additional-options' => array(), // Most options from config-export and core-rsync unusable.
'examples' => array(
'drush config-pull @prod @stage' => "Export config from @prod and transfer to @stage.",
'drush config-pull @prod @self --label=vcs' => "Export config from @prod and transfer to the 'vcs' config directory of current site.",
),
'options' => array(
'safe' => 'Validate that there are no git uncommitted changes before proceeding',
'label' => "A config directory label (i.e. a key in \$config_directories array in settings.php). Defaults to 'sync'",
),
'topics' => array('docs-aliases', 'docs-config-exporting'),
);

return $items;
}

Expand Down Expand Up @@ -278,8 +302,12 @@ function drush_config_set($config_name, $key = NULL, $data = NULL) {
}
}

/*
* If provided $destination is not TRUE and not empty, make sure it is writable.
*/
function drush_config_export_validate() {
if ($destination = drush_get_option('destination')) {
$destination = drush_get_option('destination');
if ($destination !== TRUE && !empty($destination)) {
$additional = array();
$values = drush_sitealias_evaluate_path($destination, $additional, TRUE);
if (!isset($values['path'])) {
Expand Down Expand Up @@ -315,10 +343,18 @@ function drush_config_export($destination = NULL) {

// Determine which target directory to use.
if ($target = drush_get_option('destination')) {
$destination_dir = $target;
// It is important to be able to specify a destination directory that
// does not exist yet, for exporting on remote systems
drush_mkdir($destination_dir);
if ($target === TRUE) {
// User did not pass a specific value for --destination. Make one.
/** @var drush_version_control_backup $backup */
$backup = drush_include_engine('version_control', 'backup');
$destination_dir = $backup->prepare_backup_dir('config-export');
}
else {
$destination_dir = $target;
// It is important to be able to specify a destination directory that
// does not exist yet, for exporting on remote systems
drush_mkdir($destination_dir);
}
}
else {
$choices = drush_map_assoc(array_keys($config_directories));
Expand Down Expand Up @@ -507,7 +543,7 @@ function drush_config_import_validate() {
}

/**
* Presently, the only configuraiton storage filter that is supported
* Presently, the only configuration storage filter that is supported
* is the 'CoreExtensionFilter'. If other use cases arise that are
* not supported by Drupal's configuration override system, then we
* could add a hook here via drush_command_invoke_all('drush_storage_filters');
Expand Down Expand Up @@ -715,6 +751,65 @@ function drush_config_edit($config_name = '') {
}
}

/**
* Config pull validate callback
*
*/
function drush_config_pull_validate($source, $destination) {
if (drush_get_option('safe')) {
$return = drush_invoke_process($destination, 'core-execute', array('git diff --quiet'), array('escape' => 0));
if ($return['error_status']) {
return drush_set_error('DRUSH_GIT_DIRTY', 'There are uncommitted changes in your git working copy.');
}
}
}

/**
* Config pull command callback
*
* @param string $label
* The config label which receives the transferred files.
*/
function drush_config_pull($source, $destination) {
// @todo drush_redispatch_get_options() assumes you will execute same command. Not good.
$global_options = drush_redispatch_get_options() + array(
'strict' => 0,
);

$backend_options = array('interactive' => FALSE);
if (drush_get_context('DRUSH_SIMULATE')) {
$backend_options['backend-simulate'] = TRUE;
}

$export_options = array(
// Use the standard backup directory on Destination.
'destination' => TRUE,
);
drush_log(dt('Starting to export configuration on Target.'), 'ok');
$return = drush_invoke_process($source, 'config-export', array(), $global_options + $export_options, $backend_options);
if ($return['error_status']) {
return drush_set_error('DRUSH_CONFIG_PULL_EXPORT_FAILED', dt('Config-export failed.'));
}
else {
// Trailing slash assures that transer files and not the containing dir.
$export_path = $return['object'] . '/';
}

$rsync_options = array(
'remove-source-files' => TRUE,
'delete' => TRUE,
);
$label = drush_get_option('label', 'sync');
$runner = drush_get_runner($source, $destination);
drush_log(dt('Starting to rsync configuration from Source to Local.'), 'ok');
$return = drush_invoke_process($runner, 'core-rsync', array("$source:$export_path", "$destination:%config-$label"), $rsync_options, $backend_options);
if ($return['error_status']) {
return drush_set_error('DRUSH_CONFIG_PULL_RSYNC_FAILED', dt('Config-pull rsync failed.'));
}

drush_backend_set_result($return['object']);
}

/**
* Show and return a config object
*
Expand Down
8 changes: 4 additions & 4 deletions commands/core/core.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function core_drush_command() {
'cache-clear',
),
'options' => array(
'entity-updates' => 'Run automatic entity schema updates at the end of any update hooks.',
'entity-updates' => 'Run automatic entity schema updates at the end of any update hooks. Defaults to --no-entity-updates.',
),
'aliases' => array('updb'),
);
Expand Down Expand Up @@ -179,7 +179,7 @@ function core_drush_command() {
'item' => 'Optional. The status item line(s) to display.',
),
'options' => array(
'show-passwords' => 'Show database password.',
'show-passwords' => 'Show database password. Defaults to --no-show-passwords.',
'full' => 'Show all file paths and drush aliases in the report, even if there are a lot.',
'project' => array(
'description' => 'One or more projects that should be added to the path list',
Expand Down Expand Up @@ -281,7 +281,7 @@ function core_drush_command() {
'command' => 'The shell command to be executed.',
),
'options' => array(
'escape' => 'Escape parameters before executing them with the shell. Default is escape; use --escape=0 to disable.',
'escape' => 'Escape parameters before executing them with the shell. Default is escape; use --no-escape to disable.',
) + drush_shell_exec_proc_build_options(),
'required-arguments' => TRUE,
'allow-additional-options' => TRUE,
Expand Down Expand Up @@ -868,7 +868,7 @@ function drush_core_status() {

// Command callback. Show all global options. Exposed via topic command.
function drush_core_global_options() {
drush_print(dt('These options are applicable to most drush commands.'));
drush_print(dt('These options are applicable to most drush commands. Most options can be disabled by using --no-option (i.e. --no-debug to disable --debug.)'));
drush_print();
$fake = drush_global_options_command(FALSE);
return drush_format_help_section($fake, 'options');
Expand Down
2 changes: 1 addition & 1 deletion commands/core/outputformat.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function outputformat_drush_engine_type_info() {
'hidden' => TRUE,
),
'field-labels' => array(
'description' => 'Add field labels before first line of data. Default is on; --field-labels=0 to disable.',
'description' => 'Add field labels before first line of data. Default is on; use --no-field-labels to disable.',
'default' => '1',
'key' => 'include-field-labels',
),
Expand Down
1 change: 1 addition & 0 deletions commands/core/rsync.core.inc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function drush_core_rsync($source, $destination, $additional_options = array())
}
}

drush_backend_set_result($destination_path);
// Go ahead and call rsync with the paths we determined
return drush_core_exec_rsync($source_path, $destination_path, $options);
}
Expand Down
2 changes: 1 addition & 1 deletion commands/core/site_install.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function site_install_drush_command() {
'description' => 'A short language code. Sets the default site language. Language files must already be present. You may use download command to get them.',
'example-value' => 'en-GB',
),
'clean-url'=> 'Defaults to 1',
'clean-url'=> 'Defaults to clean; use --no-clean-url to disable. Note that Drupal 8 and later requires clean.',
'site-name' => 'Defaults to Site-Install',
'site-mail' => 'From: for system mailings. Defaults to [email protected]',
'sites-subdir' => array(
Expand Down
1 change: 1 addition & 0 deletions commands/core/sitealias.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ function drush_sitealias_site_set($site = '@none') {
elseif (drush_mkdir(dirname($filename), TRUE)) {
if (file_put_contents($filename, $site)) {
drush_print($success_message);
drush_log(dt("Site information stored in !file", array('!file' => $filename)));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion commands/core/ssh.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function ssh_drush_command() {
'bash' => 'Bash to execute on target. Optional, except when site-alias is a list.',
),
'options' => array(
'cd' => "Directory to change to. Use a full path, TRUE for the site's Drupal root directory, or FALSE for the remote user's home directory. Defaults to the Drupal root.",
'cd' => "Directory to change to. Use a full path, TRUE for the site's Drupal root directory, or --no-cd for the ssh default (usually the remote user's home directory). Defaults to the Drupal root.",
) + drush_shell_exec_proc_build_options(),
'handle-remote-commands' => TRUE,
'strict-option-handling' => TRUE,
Expand Down
4 changes: 2 additions & 2 deletions commands/runserver/runserver.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ function runserver_drush_command() {
'description' => 'Runs PHP\'s built-in http server for development.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
'arguments' => array(
'addr:port/path' => 'Host IP address and port number to bind to and path to open in web browser. Format is addr:port/path, default 127.0.0.1:8888, all elements optional. See examples for shorthand.',
'addr:port/path' => 'Host IP address and port number to bind to and path to open in web browser. Format is addr:port/path, default 127.0.0.1:8888, all elements optional. See examples for shorthand. Only opens a browser if a path is specified.',
),
'options' => array(
'variables' => 'Key-value array of variables to override in the $conf array for the running site. By default disables drupal_http_request_fails to avoid errors on Windows (which supports only one connection at a time). Comma delimited list of name=value pairs (or array in drushrc).',
'default-server' => 'A default addr:port/path to use for any values not specified as an argument.',
'user' => 'If opening a web browser, automatically log in as this user (user ID or username). Default is to log in as uid 1.',
'browser' => 'If opening a web browser, which browser to user (defaults to operating system default).',
'browser' => 'If opening a web browser, which browser to user (defaults to operating system default). Use --no-browser to avoid opening a browser.',
'dns' => 'Resolve hostnames/IPs using DNS/rDNS (if possible) to determine binding IPs and/or human friendly hostnames for URLs and browser.',
),
'aliases' => array('rs'),
Expand Down
16 changes: 2 additions & 14 deletions commands/sql/sqlsync.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function drush_sqlsync_sql_sync($source, $destination) {
}
elseif ($source_is_local && $destination_is_local) {
$destination_dump_path = $source_dump_path;
$do_rsync = false;
$do_rsync = FALSE;
}
else {
$tmp = '/tmp'; // Our fallback plan.
Expand All @@ -249,19 +249,7 @@ function drush_sqlsync_sql_sync($source, $destination) {
// Cleanup if this command created the dump file.
$rsync_options['remove-source-files'] = TRUE;
}

// Try run to rsync locally so that aliases always resolve. https://github.com/drush-ops/drush/issues/668
if (drush_sitealias_is_remote_site($source) === FALSE) {
$runner = $source;
}
elseif (drush_sitealias_is_remote_site($destination) === FALSE) {
$runner = $destination;
}
else {
// Both are remote. Arbitrarily run rsync on destination. Aliases must be defined there (for now).
// @todo Add an option for choosing runner? Resolve aliases before rsync?
$runner = $destination;
}
$runner = drush_get_runner($source, $destination);
$return = drush_invoke_process($runner, 'core-rsync', array("$source:$source_dump_path", "$destination:$destination_dump_path"), $rsync_options);
drush_log(dt('Copying dump file from Source to Destination.'), 'ok');
if ($return['error_status']) {
Expand Down
2 changes: 1 addition & 1 deletion commands/user/user.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function user_drush_command() {
'path' => 'Optional path to redirect to after logging in.',
),
'options' => array(
'browser' => 'Optional value denotes which browser to use (defaults to operating system default). Set to 0 to suppress opening a browser.',
'browser' => 'Optional value denotes which browser to use (defaults to operating system default). Use --no-browser to suppress opening a browser.',
'uid' => 'A uid to log in as.',
'redirect-port' => 'A custom port for redirecting to (e.g. when running within a Vagrant environment)',
'name' => 'A user name to log in as.',
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"require": {
"php": ">=5.4.5",
"psy/psysh": "~0.5",
"symfony/yaml": "~2.2",
"symfony/yaml": "2.7.*",
"symfony/var-dumper": "^2.6.3",
"pear/console_table": "~1.2.0"
},
"require-dev": {
"phpunit/phpunit": ">=3.5",
"symfony/process": "2.4.5"
"symfony/process": "2.7.*"
},
"suggest": {
"ext-pcntl": "*",
Expand Down
Loading

0 comments on commit 0878e99

Please sign in to comment.