summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJSCSJSCS2013-03-21 04:54:08 (GMT)
committer Greg Anderson2013-03-21 04:54:08 (GMT)
commit7d5dcec78dd68fb5a734543331d09909d38c4c3a (patch)
tree3d7e29a2ead0c3e6b8b9c8482a63fbb8c10bbc79
parentba49e35e61e6c99fc17ad4cc951beb1ecd661311 (diff)
Issue #1110486 by JSCSJSCS, greg.1.anderson: Fix options defined in config files without values for "strict options" commands (e.g. "--delete" option to rsync)
-rw-r--r--commands/core/core.drush.inc8
-rw-r--r--commands/core/rsync.core.inc6
-rw-r--r--examples/example.aliases.drushrc.php36
-rw-r--r--includes/command.inc7
4 files changed, 50 insertions, 7 deletions
diff --git a/commands/core/core.drush.inc b/commands/core/core.drush.inc
index 16f512e..707ddb0 100644
--- a/commands/core/core.drush.inc
+++ b/commands/core/core.drush.inc
@@ -226,7 +226,6 @@ function core_drush_command() {
),
'options' => array(
'mode' => 'The unary flags to pass to rsync; --mode=rultz implies rsync -rultz. Default is -akz.',
- 'RSYNC-FLAG' => 'Most rsync flags passed to drush sync will be passed on to rsync. See rsync documentation.',
'exclude-conf' => 'Excludes settings.php from being rsynced. Default.',
'include-conf' => 'Allow settings.php to be rsynced. Default is to exclude settings.php.',
'include-vcs' => 'Include special version control directories (e.g. .svn). Default is to exclude vcs files.',
@@ -235,11 +234,14 @@ function core_drush_command() {
'exclude-other-sites' => 'Exclude all directories in "sites/" except for "sites/all" and the site directory for the site being synced. Note: if the site directory is different between the source and destination, use --exclude-sites followed by "drush rsync @from:%site @to:%site"',
'exclude-paths' => 'List of paths to exclude, seperated by : (Unix-based systems) or ; (Windows).',
'include-paths' => 'List of paths to include, seperated by : (Unix-based systems) or ; (Windows).',
+ '{rsync-option-name}' => "Replace {rsync-option-name} with the rsync option (or option='value') that you would like to pass through to rsync. Examples include --delete, --exclude=*.sql, --filter='merge /etc/rsync/default.rules', etc. See the rsync documentation for a complete explaination of all the rsync options and values.",
+
),
'strict-option-handling' => TRUE,
'examples' => array(
- 'drush rsync @dev @stage' => 'Rsync Drupal root from dev to stage (one of which must be local).',
- 'drush rsync ./ @stage:%files/img' => 'Rsync all files in the current directory to the \'img\' directory in the file storage folder on stage.',
+ 'drush rsync @dev @stage' => 'Rsync Drupal root from Drush alias dev to the alias stage (one of which must be local).',
+ 'drush rsync ./ @stage:%files/img' => 'Rsync all files in the current directory to the \'img\' directory in the file storage folder on the Drush alias stage.',
+ 'drush -s rsync @dev @stage --exclude=*.sql --delete' => "Simulate Rsync Drupal root from the Drush alias dev to the alias stage (one of which must be local), excluding all files that match the filter '*.sql' and delete all files on the destination that are no longer on the source.",
),
'aliases' => array('rsync'),
'topics' => array('docs-aliases'),
diff --git a/commands/core/rsync.core.inc b/commands/core/rsync.core.inc
index eec5747..48a6a87 100644
--- a/commands/core/rsync.core.inc
+++ b/commands/core/rsync.core.inc
@@ -67,7 +67,7 @@ function drush_core_rsync($source, $destination, $additional_options = array())
$options .= ' ' . $original_option;
}
}
-
+
// Go ahead and call rsync with the paths we determined
return drush_core_exec_rsync($source_path, $destination_path, $options);
}
@@ -98,7 +98,7 @@ function drush_core_rsync($source, $destination, $additional_options = array())
* TRUE on success, FALSE on failure.
*/
function drush_core_call_rsync($source, $destination, $additional_options = array(), $include_settings_is_default = TRUE, $live_output = TRUE) {
- $options = _drush_build_rsync_options($additional_options, $include_settings_is_default);
+ $options = _drush_build_rsync_options($additional_options, $include_settings_is_default);
return drush_core_exec_rsync($source, $destination, $options, $additional_options, $live_output);
}
@@ -187,7 +187,7 @@ function _drush_build_rsync_options($additional_options, $include_settings_is_de
}
}
if ((isset($test_option)) && !in_array($test_option, $options_to_exclude) && (isset($value) && !is_array($value))) {
- if ($value === TRUE) {
+ if (($value === TRUE) || (!isset($value))) {
$options .= " --$test_option";
}
else {
diff --git a/examples/example.aliases.drushrc.php b/examples/example.aliases.drushrc.php
index bd8378b..23d79c7 100644
--- a/examples/example.aliases.drushrc.php
+++ b/examples/example.aliases.drushrc.php
@@ -211,6 +211,42 @@
* in fact are removed before making a backend invoke call (for example). These
* kinds of values are useful in conjunction with shell aliases. See
* `drush topic docs-shell-aliases` for more information on this.
+ * - rsync command options have specific requirements in order to
+ * be passed through by Drush. See the comments on the sample below:
+ *
+ * 'command-specific' => array (
+ * 'core-rsync' => array (
+ *
+ * // single-letter rsync options are placed in the 'mode' key
+ * // instead of adding '--mode=rultvz' to drush rsync command.
+ * 'mode' => 'rultvz',
+ *
+ * // multi-letter rsync options without values must be set to
+ * // TRUE or NULL to work (i.e. setting $VALUE to 1, 0, or ''
+ * // will not work).
+ * 'delete' => TRUE,
+ *
+ * // wrapping an option's value in "" preserves inner '' on output;
+ * // but is not always required.
+ * 'exclude' => "'*.gz'",
+ *
+ * // cannot add multiple options of same key; each key overwrites
+ * // the previous key's value. This 'exclude' option will overwrite
+ * // the previous one above.
+ * 'exclude' => '*.sql',
+ *
+ * // if you need multiple exludes, use an rsync exclude file
+ * 'exclude-from' => "'/etc/rsync/exclude.rules'",
+ *
+ * // filter options with white space must be wrapped in "" to preserve
+ * // the inner ''.
+ * 'filter' => "'exclude *.sql'",
+ *
+ * // if you need multple filter options, see rsync merge-file options
+ * 'filter' => "'merge /etc/rsync/default.rules'",
+ * ),
+ * ),
+ *
* Some examples appear below. Remove the leading hash signs to enable.
*/
#$aliases['stage'] = array(
diff --git a/includes/command.inc b/includes/command.inc
index 5838771..c6d6dc3 100644
--- a/includes/command.inc
+++ b/includes/command.inc
@@ -1601,7 +1601,12 @@ function drush_get_original_cli_args_and_options($command = NULL) {
$command_options = ($command == NULL) ? array() : _drush_get_command_options($command);
foreach ($command_specific_options as $key => $value) {
if (!array_key_exists($key, $command_options)) {
- $args[] = "--$key=$value";
+ if (($value === TRUE) || (!isset($value))) {
+ $args[] = "--$key";
+ }
+ else {
+ $args[] = "--$key=$value";
+ }
}
}
return $args;