Skip to content

Commit

Permalink
CLI-1473: Pull default site if non-interactive. (#1839)
Browse files Browse the repository at this point in the history
* Pull default site if non-interactive.

If your site has multiple databases, acli pull:db --no-interaction will not pull the default database, which is the logical default.

* reorder sites in question

* array_unshift

---------

Co-authored-by: Dane Powell <[email protected]>
  • Loading branch information
charginghawk and danepowell authored Jan 9, 2025
1 parent 98ce828 commit 428a6e2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/Command/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,10 @@ private function getCloudSites(EnvironmentResponse $cloudEnvironment): array
$process = $this->sshHelper->executeCommand($cloudEnvironment->sshUrl, $command, false);
$sites = array_filter(explode("\n", trim($process->getOutput())));
if ($process->isSuccessful() && $sites) {
if ($key = array_search('default', $sites, true)) {
unset($sites[$key]);
array_unshift($sites, 'default');
}
return $sites;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/src/Commands/Pull/PullCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testPull(): void
$this->mockGetFilesystem($localMachineHelper);
$parts = explode('.', $environment->ssh_url);
$sitegroup = reset($parts);
$this->mockExecuteRsync($localMachineHelper, $environment, '/mnt/files/' . $sitegroup . '.' . $environment->name . '/sites/bar/files/', $this->projectDir . '/docroot/sites/bar/files');
$this->mockExecuteRsync($localMachineHelper, $environment, '/mnt/files/' . $sitegroup . '.' . $environment->name . '/sites/default/files/', $this->projectDir . '/docroot/sites/default/files');
$this->command->sshHelper = $sshHelper->reveal();

// Pull database.
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function testRefreshCloudFiles(): void
$this->mockGetFilesystem($localMachineHelper);
$parts = explode('.', $selectedEnvironment->ssh_url);
$sitegroup = reset($parts);
$this->mockExecuteRsync($localMachineHelper, $selectedEnvironment, '/mnt/files/' . $sitegroup . '.' . $selectedEnvironment->name . '/sites/bar/files/', $this->projectDir . '/docroot/sites/bar/files');
$this->mockExecuteRsync($localMachineHelper, $selectedEnvironment, '/mnt/files/' . $sitegroup . '.' . $selectedEnvironment->name . '/sites/default/files/', $this->projectDir . '/docroot/sites/default/files');

$this->command->sshHelper = $sshHelper->reveal();

Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/src/Commands/Push/PushFilesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ protected function mockExecuteCloudRsync(
'rsync',
'-avPhze',
'ssh -o StrictHostKeyChecking=no',
$this->projectDir . '/docroot/sites/bar/files/',
$environment->ssh_url . ':/mnt/files/' . $sitegroup . '.' . $environment->name . '/sites/bar/files',
$this->projectDir . '/docroot/sites/default/files/',
$environment->ssh_url . ':/mnt/files/' . $sitegroup . '.' . $environment->name . '/sites/default/files',
];
$localMachineHelper->execute($command, Argument::type('callable'), null, true)
->willReturn($process->reveal())
Expand Down

0 comments on commit 428a6e2

Please sign in to comment.