Skip to content

Commit fd0c5d7

Browse files
Use --format=json in sql:sync (#3936)
* Use format json instead of format string when fetching database credentials in sql:sync. Make '@self' aliases more discoverable. * Use site-alias 3.0.0-beta3
1 parent c7f062b commit fd0c5d7

File tree

12 files changed

+133
-80
lines changed

12 files changed

+133
-80
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ sut/*
1414
sut/drush/sites/*test.site.yml
1515
/sandbox/
1616
.env
17+
# Test fixtures
18+
sut/drush/sites/synctest.site.yml

.scenarios.lock/php5/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"consolidation/filter-via-dot-access-data": "^1",
6464
"consolidation/output-formatters": "^3.3.1",
6565
"consolidation/robo": "^1.4.6",
66-
"consolidation/site-alias": "^3.0.0-beta1",
66+
"consolidation/site-alias": "^3.0.0-beta3",
6767
"consolidation/site-process": "^2.0.0-beta5",
6868
"grasmash/yaml-expander": "^1.1.1",
6969
"league/container": "~2",

.scenarios.lock/php5/composer.lock

Lines changed: 17 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ shallow_clone: false
33
platform: 'x86'
44
clone_folder: C:\projects\work
55
branches:
6-
except:
7-
- gh-pages
6+
only:
7+
- master
88

99
## Cache composer bits
1010
cache:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"consolidation/filter-via-dot-access-data": "^1",
4040
"consolidation/output-formatters": "^3.3.1",
4141
"consolidation/robo": "^1.4.6",
42-
"consolidation/site-alias": "^3.0.0-beta1",
42+
"consolidation/site-alias": "^3.0.0-beta3",
4343
"consolidation/site-process": "^2.0.0-beta5",
4444
"grasmash/yaml-expander": "^1.1.1",
4545
"league/container": "~2",

composer.lock

Lines changed: 17 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/backend.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function _drush_backend_integrate($data, $backend_options, $outputted) {
283283
// Drush (version 4.x) that does not send backend packets, then we will
284284
// not have processed the log entries yet, and must print them here.
285285
$received_packets = drush_get_context('DRUSH_RECEIVED_BACKEND_PACKETS', FALSE);
286-
if (is_array($data['log']) && $backend_options['log'] && (!$received_packets)) {
286+
if (is_array($data['log']) && !empty($backend_options['log']) && (!$received_packets)) {
287287
foreach($data['log'] as $log) {
288288
$message = is_array($log['message']) ? implode("\n", $log['message']) : $log['message'];
289289
if (isset($backend_options['#output-label'])) {
@@ -303,7 +303,7 @@ function _drush_backend_integrate($data, $backend_options, $outputted) {
303303
if (drush_cmp_error('DRUSH_APPLICATION_ERROR') && !empty($data['output'])) {
304304
drush_set_error("DRUSH_APPLICATION_ERROR", dt("Output from failed command :\n !output", ['!output' => $data['output']]));
305305
}
306-
elseif ($backend_options['output']) {
306+
elseif (!empty($backend_options['output'])) {
307307
_drush_backend_print_output($data['output'], $backend_options);
308308
}
309309
}

src/Commands/sql/SqlSyncCommands.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,14 @@ public function databaseName(SiteAlias $record)
113113
return 'simulated_db';
114114
}
115115

116-
$process = $this->processManager()->drush($record, 'core-status', ['db-name'], ['format' => 'string']);
116+
$process = $this->processManager()->drush($record, 'core-status', ['db-name'], ['format' => 'json']);
117117
$process->setSimulated(false);
118118
$process->mustRun();
119-
return trim($process->getOutput());
119+
$data = $process->getOutputAsJson();
120+
if (!isset($data['db-name'])) {
121+
throw new \Exception('Could not look up database name for ' . $record->name());
122+
}
123+
return trim($data['db-name']);
120124
}
121125

122126
/**

sut/drush/sites/self.site.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fake:
2+
root: /path/to/fake/root
3+
uri: https://fake.example.com

tests/functional/RsyncTest.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @group commands
1010
* @group slow
1111
*/
12-
class RsyncCase extends CommandUnishTestCase
12+
class RsyncTest extends CommandUnishTestCase
1313
{
1414

1515
public function setUp()
@@ -34,21 +34,6 @@ public function testRsyncSimulated()
3434
'alias-path' => __DIR__ . '/resources/alias-fixtures',
3535
];
3636

37-
// Test simulated simple rsync with two local sites
38-
$this->drush('rsync', ['@example.stage', '@example.dev'], $options, null, null, self::EXIT_SUCCESS, '2>&1');
39-
$expected = "[notice] Simulating: rsync -e 'ssh ' -akz /path/to/stage /path/to/dev";
40-
$this->assertOutputEquals($expected);
41-
42-
// Test simulated rsync with relative paths
43-
$this->drush('rsync', ['@example.dev:files', '@example.stage:files'], $options, null, null, self::EXIT_SUCCESS, '2>&1');
44-
$expected = "[notice] Simulating: rsync -e 'ssh ' -akz /path/to/dev/files /path/to/stage/files";
45-
$this->assertOutputEquals($expected);
46-
47-
// Test simulated rsync on local machine with a remote target
48-
$this->drush('rsync', ['@example.dev:files', '@example.live:files'], $options, null, null, self::EXIT_SUCCESS, '2>&1');
49-
$expected = "[notice] Simulating: rsync -e 'ssh -o PasswordAuthentication=example' -akz /path/to/dev/files [email protected]:/path/on/service-provider/files";
50-
$this->assertOutputEquals($expected);
51-
5237
// Test simulated backend invoke.
5338
// Note that command-specific options are not processed for remote
5439
// targets. The aliases are not interpreted at all until they recache

0 commit comments

Comments
 (0)