Skip to content

Commit

Permalink
Remove --file option form config-edit
Browse files Browse the repository at this point in the history
It duplicates config-import --partial, and is buggy. A fix for --partial is coming in #2069
  • Loading branch information
weitzman committed Mar 18, 2016
1 parent 6d5997c commit ba7d179
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 49 deletions.
35 changes: 5 additions & 30 deletions commands/core/config.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ function config_drush_command() {
'arguments' => array(
'config-name' => 'The config object name, for example "system.site".',
),
'options' => array(
'file' => 'Import from a file instead of interactively editing a given config.',
),
'global-options' => array('editor', 'bg'),
'examples' => array(
'drush config-edit image.style.large' => 'Edit the image style configurations.',
Expand Down Expand Up @@ -696,12 +693,6 @@ function _drush_config_import_partial(FileStorage $source) {
* Edit command callback.
*/
function drush_config_edit($config_name = '') {
$file = drush_get_option('file', FALSE);
if (empty($config_name) && $file) {
// If not provided, assume config name from the given file.
$config_name = basename($file, '.yml');
}

// Identify and validate input.
if ($config_name) {
$config = Drupal::configFactory()->getEditable($config_name);
Expand All @@ -724,29 +715,13 @@ function drush_config_edit($config_name = '') {
$active_storage = $config->getStorage();
$contents = $active_storage->read($config_name);

// Write tmp YAML file for editing
$temp_storage = new FileStorage(drush_tempdir());
if ($file) {
$temp_storage->write($config_name, \Symfony\Component\Yaml\Yaml::parse(file_get_contents($file)));
// Show difference.
$existing = new FileStorage(drush_tempdir());
$existing->write($config_name, $contents);
// @todo Can DiffFormatter produce a CLI pretty diff?
drush_shell_exec('diff -u %s %s', $existing->getFilePath($config_name), $temp_storage->getFilePath($config_name));
$output = drush_shell_exec_output();
drush_print(implode("\n", $output));

if (!drush_confirm(dt('Keep these changes?'))) {
return drush_user_abort(dt('Config not edited.'));
}
}
else {
// Write tmp YAML file for editing.
$temp_storage->write($config_name, $contents);
$temp_storage->write($config_name, $contents);

// $filepath = drush_save_data_to_temp_file();
$exec = drush_get_editor();
drush_shell_exec_interactive($exec, $temp_storage->getFilePath($config_name));
}
// $filepath = drush_save_data_to_temp_file();
$exec = drush_get_editor();
drush_shell_exec_interactive($exec, $temp_storage->getFilePath($config_name));

// Perform import operation if user did not immediately exit editor.
if (!drush_get_option('bg', FALSE)) {
Expand Down
19 changes: 0 additions & 19 deletions tests/configTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,6 @@ function testConfigExportImport() {
$this->assertContains('tracker', $contents);
}

/**
* Tests editing config from a file (not interactively).
*/
public function testConfigEdit() {
// Write out edits to a file.
$config = "name: 'TEST NAME'\nmail: [email protected]";
$path = UNISH_SANDBOX . '/system.site.yml';
file_put_contents($path, $config);

$options = $this->options();
$options += array(
'file' => $path,
'yes' => NULL,
);
$this->drush('config-edit', array(), $options);
$this->drush('config-get', array('system.site'), $this->options());
$this->assertEquals($config, $this->getOutput());
}

function options() {
return array(
'yes' => NULL,
Expand Down

0 comments on commit ba7d179

Please sign in to comment.