Skip to content

Commit 6867f8f

Browse files
committed
Case 27689; handling builds that don't have a site root directory
1 parent 3495d6a commit 6867f8f

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/Command/Site/AbstractCommand.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ protected function getSiteRoot() {
241241
return $this->siteRoot;
242242
}
243243

244+
/**
245+
* Check if the current build has a site root directory.
246+
*
247+
* @return bool
248+
*/
249+
protected function hasSiteRoot() {
250+
return !is_null($this->siteRoot);
251+
}
252+
244253
/**
245254
* Helper to check that the config file exits and load the configuration.
246255
*

src/Command/Site/Checkout/AbstractRefCommand.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,20 @@ protected function gitClone() {
192192
* @throws CommandException
193193
*/
194194
protected function gitCheckout() {
195-
$commands = [
196-
sprintf('cd %s', $this->shellPath($this->getRoot())),
197-
'git fetch --all',
198-
sprintf('chmod 777 %ssites/default', $this->getWebRoot()),
199-
sprintf('chmod 777 %ssites/default/settings.php', $this->getWebRoot()),
200-
sprintf('git checkout %s --force', $this->ref),
201-
];
195+
196+
$commands = [];
197+
198+
// Fix site folder permissions.
199+
if ($this->hasSiteRoot()) {
200+
$commands[] = sprintf('chmod 777 %s', $this->getSiteRoot());
201+
$commands[] = sprintf('chmod 777 %ssettings.php', $this->getSiteRoot());
202+
}
203+
204+
// Checkout commands.
205+
$commands[] = sprintf('cd %s', $this->shellPath($this->getRoot()));
206+
$commands[] = 'git fetch --all';
207+
$commands[] = sprintf('git checkout %s --force', $this->ref);
208+
202209
$command = implode(' && ', $commands);
203210

204211
$shellProcess = $this->getShellProcess();

0 commit comments

Comments
 (0)