Completed
Push — master ( 539f62...852c44 )
by Mateusz
03:41 queued 39s
created
code/backends/CapistranoDeploymentBackend.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
 			try {
73 73
 				$args['build_filename'] = $this->packageGenerator->getPackageFilename($project->Name, $sha, $repository, $log);
74
-			} catch (Exception $e) {
74
+			} catch(Exception $e) {
75 75
 				$log->write($e->getMessage());
76 76
 				throw $e;
77 77
 			}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 			$this->extend('deployFailure', $environment, $sha, $log, $project);
111 111
 
112 112
 			$currentBuild = $environment->CurrentBuild();
113
-			if (empty($currentBuild) || (!empty($options['no_rollback']) && $options['no_rollback'] !== 'false')) {
113
+			if(empty($currentBuild) || (!empty($options['no_rollback']) && $options['no_rollback'] !== 'false')) {
114 114
 				throw new RuntimeException($command->getErrorOutput());
115 115
 			}
116 116
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			// as deploying removes .htaccess
127 127
 			$this->enableMaintenance($environment, $log, $project);
128 128
 
129
-			if (!$command->isSuccessful() || !$this->smokeTest($environment, $log)) {
129
+			if(!$command->isSuccessful() || !$this->smokeTest($environment, $log)) {
130 130
 				$this->extend('deployRollbackFailure', $environment, $currentBuild->SHA, $log, $project);
131 131
 				$log->write('Rollback failed');
132 132
 				throw new RuntimeException($command->getErrorOutput());
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
 		// Rolling back means the rollback succeeded, but ultimately the deployment
144 144
 		// has failed. Throw an exception so the job is marked as failed accordingly.
145
-		if ($rolledBack === true) {
145
+		if($rolledBack === true) {
146 146
 			throw new RuntimeException('Rollback successful');
147 147
 		}
148 148
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 		} else {
214 214
 			$environment = $dataTransfer->Environment();
215 215
 			$project = $environment->Project();
216
-			$workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID;
216
+			$workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID;
217 217
 			$archive = $dataTransfer->DataArchive();
218 218
 
219 219
 			// extract the sspak contents, we'll need these so capistrano can restore that content
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		if(!$args) {
260 260
 			$args = array();
261 261
 		}
262
-		$args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH . '/');
262
+		$args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH.'/');
263 263
 		$args['environment_id'] = $environment->ID;
264 264
 
265 265
 		// Inject env string directly into the command.
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 
275 275
 		$data = DNData::inst();
276 276
 		// Generate a capfile from a template
277
-		$capTemplate = file_get_contents(BASE_PATH . '/deploynaut/Capfile.template');
277
+		$capTemplate = file_get_contents(BASE_PATH.'/deploynaut/Capfile.template');
278 278
 		$cap = str_replace(
279 279
 			array('<config root>', '<ssh key>', '<base path>'),
280 280
 			array($data->getEnvironmentDir(), DEPLOYNAUT_SSH_KEY, BASE_PATH),
@@ -284,13 +284,13 @@  discard block
 block discarded – undo
284 284
 		if(defined('DEPLOYNAUT_CAPFILE')) {
285 285
 			$capFile = DEPLOYNAUT_CAPFILE;
286 286
 		} else {
287
-			$capFile = ASSETS_PATH . '/Capfile';
287
+			$capFile = ASSETS_PATH.'/Capfile';
288 288
 		}
289 289
 		file_put_contents($capFile, $cap);
290 290
 
291
-		$command = "{$envString}cap -f " . escapeshellarg($capFile) . " -vv $name $action ROLES=$roles";
291
+		$command = "{$envString}cap -f ".escapeshellarg($capFile)." -vv $name $action ROLES=$roles";
292 292
 		foreach($args as $argName => $argVal) {
293
-			$command .= ' -s ' . escapeshellarg($argName) . '=' . escapeshellarg($argVal);
293
+			$command .= ' -s '.escapeshellarg($argName).'='.escapeshellarg($argVal);
294 294
 		}
295 295
 
296 296
 		$log->write(sprintf('Running command: %s', $command));
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		$filepathBase = $dataArchive->generateFilepath($dataTransfer);
325 325
 		mkdir($filepathBase, 0700, true);
326 326
 
327
-		$databasePath = $filepathBase . DIRECTORY_SEPARATOR . 'database.sql';
327
+		$databasePath = $filepathBase.DIRECTORY_SEPARATOR.'database.sql';
328 328
 
329 329
 		// Backup database
330 330
 		if(in_array($dataTransfer->Mode, array('all', 'db'))) {
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 		$log->write('Creating sspak...');
363 363
 
364 364
 		$sspakFilename = sprintf('%s.sspak', $dataArchive->generateFilename($dataTransfer));
365
-		$sspakFilepath = $filepathBase . DIRECTORY_SEPARATOR . $sspakFilename;
365
+		$sspakFilepath = $filepathBase.DIRECTORY_SEPARATOR.$sspakFilename;
366 366
 
367 367
 		try {
368 368
 			$dataArchive->attachFile($sspakFilepath, $dataTransfer);
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		// Restore database into target environment
430 430
 		if(in_array($dataTransfer->Mode, array('all', 'db'))) {
431 431
 			$log->write(sprintf('Restore of database to "%s" started', $name));
432
-			$args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'database.sql');
432
+			$args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'database.sql');
433 433
 			$command = $this->getCommand('data:pushdb', 'db', $environment, $args, $log);
434 434
 			$command->run(function($type, $buffer) use($log) {
435 435
 				$log->write($buffer);
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 		// Restore assets into target environment
447 447
 		if(in_array($dataTransfer->Mode, array('all', 'assets'))) {
448 448
 			$log->write(sprintf('Restore of assets to "%s" started', $name));
449
-			$args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'assets');
449
+			$args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'assets');
450 450
 			$command = $this->getCommand('data:pushassets', 'web', $environment, $args, $log);
451 451
 			$command->run(function($type, $buffer) use($log) {
452 452
 				$log->write($buffer);
@@ -527,17 +527,17 @@  discard block
 block discarded – undo
527 527
 			}
528 528
 
529 529
 			// Produce an informational ticker roughly every $tick
530
-			if (time() > $infoTick) {
530
+			if(time() > $infoTick) {
531 531
 				$message = [];
532 532
 
533 533
 				// Collect status information from different sources.
534
-				if ($status) {
534
+				if($status) {
535 535
 					$message[] = sprintf('HTTP status code is %s', $status);
536 536
 				}
537
-				if (!$response) {
537
+				if(!$response) {
538 538
 					$message[] = 'response is empty';
539 539
 				}
540
-				if ($error = curl_error($ch)) {
540
+				if($error = curl_error($ch)) {
541 541
 					$message[] = sprintf('request error: %s', $error);
542 542
 				}
543 543
 
Please login to merge, or discard this patch.