@@ -15,7 +15,7 @@ |
||
15 | 15 | } |
16 | 16 | |
17 | 17 | public function write($message) { |
18 | - error_log('['.date('Y-m-d H:i:s').'] ' . $message .PHP_EOL, 3, $this->logFile); |
|
18 | + error_log('[' . date('Y-m-d H:i:s') . '] ' . $message . PHP_EOL, 3, $this->logFile); |
|
19 | 19 | @chmod($this->logFile, 0666); |
20 | 20 | } |
21 | 21 |
@@ -51,7 +51,7 @@ |
||
51 | 51 | |
52 | 52 | public function Link() { |
53 | 53 | // Use a get-var for branch so that it can handle unsafe chars better |
54 | - return Controller::join_links($this->project->Link(), 'branch?name='.urlencode($this->Name())); |
|
54 | + return Controller::join_links($this->project->Link(), 'branch?name=' . urlencode($this->Name())); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -75,7 +75,7 @@ |
||
75 | 75 | * @return ArrayList |
76 | 76 | */ |
77 | 77 | public function References() { |
78 | - if($this->references !== null ) { |
|
78 | + if($this->references !== null) { |
|
79 | 79 | return $this->references; |
80 | 80 | } |
81 | 81 | $this->references = new ArrayList(); |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | public function getProjectPaths() { |
166 | 166 | $paths = array(); |
167 | 167 | if(!file_exists($this->getEnvironmentDir())) { |
168 | - throw new Exception('The environment directory '.$this->getEnvironmentDir().' doesn\'t exist. Create it first and add some projects to it.'); |
|
168 | + throw new Exception('The environment directory ' . $this->getEnvironmentDir() . ' doesn\'t exist. Create it first and add some projects to it.'); |
|
169 | 169 | } |
170 | 170 | foreach(scandir($this->getEnvironmentDir()) as $project) { |
171 | 171 | // Exlcude dot-prefixed directories (.git was getting in the way) |
172 | 172 | if(preg_match('/^[^\.]/', $project)) { |
173 | - $path = $this->getEnvironmentDir().'/'.$project; |
|
174 | - if(is_dir($path) && $project!='.' && $project!='..') { |
|
173 | + $path = $this->getEnvironmentDir() . '/' . $project; |
|
174 | + if(is_dir($path) && $project != '.' && $project != '..') { |
|
175 | 175 | $paths[] = $project; |
176 | 176 | } |
177 | 177 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | $paths = array(); |
191 | 191 | if(!file_exists($baseDir)) { |
192 | - throw new Exception('Environment directory '.$baseDir.' doesn\'t exist. Create it first.'); |
|
192 | + throw new Exception('Environment directory ' . $baseDir . ' doesn\'t exist. Create it first.'); |
|
193 | 193 | } |
194 | 194 | // Search the directory for config files. |
195 | 195 | foreach(scandir($baseDir) as $environmentFile) { |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @return boolean true if $member can upload archives linked to this environment, false if they can't. |
255 | 255 | */ |
256 | 256 | public function canMoveTo($targetEnv, $member = null) { |
257 | - if ($this->Environment()->Project()->ID!=$targetEnv->Project()->ID) { |
|
257 | + if($this->Environment()->Project()->ID != $targetEnv->Project()->ID) { |
|
258 | 258 | // We don't permit moving snapshots between projects at this stage. |
259 | 259 | return false; |
260 | 260 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | if(Permission::checkMember($member, 'ADMIN')) return true; |
267 | 267 | |
268 | 268 | // Checks if the user can actually access the archive. |
269 | - if (!$this->canDownload($member)) return false; |
|
269 | + if(!$this->canDownload($member)) return false; |
|
270 | 270 | |
271 | 271 | // Hooks into ArchiveUploaders permission to prevent proliferation of permission checkboxes. |
272 | 272 | // Bypasses the quota check - we don't need to check for it as long as we move the snapshot within the project. |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $archive = $this; |
285 | 285 | $envs = $this->Environment()->Project()->DNEnvironmentList() |
286 | 286 | ->filterByCallback(function($item) use ($archive) { |
287 | - return $archive->EnvironmentID!=$item->ID && $archive->canMoveTo($item); |
|
287 | + return $archive->EnvironmentID != $item->ID && $archive->canMoveTo($item); |
|
288 | 288 | }); |
289 | 289 | |
290 | 290 | return $envs; |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | "CanBackupGroups" => "Group", |
108 | 108 | "ArchiveUploaders" => "Member", // Who can upload archive files linked to this environment |
109 | 109 | "ArchiveUploaderGroups" => "Group", |
110 | - "ArchiveDownloaders" => "Member", // Who can download archive files from this environment |
|
110 | + "ArchiveDownloaders" => "Member", // Who can download archive files from this environment |
|
111 | 111 | "ArchiveDownloaderGroups" => "Group", |
112 | - "ArchiveDeleters" => "Member", // Who can delete archive files from this environment, |
|
112 | + "ArchiveDeleters" => "Member", // Who can delete archive files from this environment, |
|
113 | 113 | "ArchiveDeleterGroups" => "Group", |
114 | 114 | "PipelineApprovers" => "Member", // Who can approve / reject pipelines from this environment |
115 | 115 | "PipelineApproverGroups" => "Group", |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function CanCancelPipeline() { |
293 | 293 | // do we have a current pipeline |
294 | - if ($this->HasCurrentPipeline()) { |
|
294 | + if($this->HasCurrentPipeline()) { |
|
295 | 295 | return $this->CurrentPipeline()->canAbort(); |
296 | 296 | } |
297 | 297 | return false; |
@@ -599,22 +599,22 @@ discard block |
||
599 | 599 | // The DeployHistory function is far too slow to use for this |
600 | 600 | $deploy = DNDeployment::get()->filter(array('EnvironmentID' => $this->ID, 'Status' => 'Finished'))->sort('LastEdited DESC')->first(); |
601 | 601 | |
602 | - if (!$deploy || (!$deploy->SHA)) { |
|
602 | + if(!$deploy || (!$deploy->SHA)) { |
|
603 | 603 | return false; |
604 | 604 | } |
605 | 605 | |
606 | 606 | $repo = $this->Project()->getRepository(); |
607 | - if (!$repo) { |
|
607 | + if(!$repo) { |
|
608 | 608 | return $deploy; |
609 | 609 | } |
610 | 610 | |
611 | 611 | try { |
612 | 612 | $commit = $repo->getCommit($deploy->SHA); |
613 | - if ($commit) { |
|
613 | + if($commit) { |
|
614 | 614 | $deploy->Message = Convert::raw2xml($commit->getMessage()); |
615 | 615 | } |
616 | 616 | // We can't find this SHA, so we ignore adding a commit message to the deployment |
617 | - } catch (Exception $ex) { } |
|
617 | + } catch(Exception $ex) { } |
|
618 | 618 | |
619 | 619 | return $deploy; |
620 | 620 | } |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | $deploy->Message = Convert::raw2xml($commit->getMessage()); |
645 | 645 | } |
646 | 646 | // We can't find this SHA, so we ignore adding a commit message to the deployment |
647 | - } catch (Exception $ex) { } |
|
647 | + } catch(Exception $ex) { } |
|
648 | 648 | $ammendedHistory->push($deploy); |
649 | 649 | } |
650 | 650 | |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * @return string |
683 | 683 | */ |
684 | 684 | public function Link() { |
685 | - return $this->Project()->Link()."/environment/" . $this->Name; |
|
685 | + return $this->Project()->Link() . "/environment/" . $this->Name; |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | // Add actions |
888 | 888 | $action = new FormAction('check', 'Check Connection'); |
889 | 889 | $action->setUseButtonTag(true); |
890 | - $action->setAttribute('data-url', Director::absoluteBaseURL().'naut/api/'.$this->Project()->Name.'/'.$this->Name.'/ping'); |
|
890 | + $action->setAttribute('data-url', Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping'); |
|
891 | 891 | $fields->insertBefore($action, 'Name'); |
892 | 892 | |
893 | 893 | // Allow extensions |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | */ |
951 | 951 | public function onBeforeWrite() { |
952 | 952 | parent::onBeforeWrite(); |
953 | - if($this->Name && $this->Name.'.rb' != $this->Filename) { |
|
954 | - $this->Filename = $this->Name.'.rb'; |
|
953 | + if($this->Name && $this->Name . '.rb' != $this->Filename) { |
|
954 | + $this->Filename = $this->Name . '.rb'; |
|
955 | 955 | } |
956 | 956 | $this->checkEnvironmentPath(); |
957 | 957 | $this->writeConfigFile(); |
@@ -976,11 +976,11 @@ discard block |
||
976 | 976 | if(!$this->config()->get('allow_web_editing')) return; |
977 | 977 | |
978 | 978 | // Create a basic new environment config from a template |
979 | - if( !$this->envFileExists() |
|
979 | + if(!$this->envFileExists() |
|
980 | 980 | && $this->Filename |
981 | 981 | && $this->CreateEnvConfig |
982 | 982 | ) { |
983 | - $templateFile = $this->config()->template_file ?: BASE_PATH.'/deploynaut/environment.template'; |
|
983 | + $templateFile = $this->config()->template_file ?: BASE_PATH . '/deploynaut/environment.template'; |
|
984 | 984 | file_put_contents($this->getConfigFilename(), file_get_contents($templateFile)); |
985 | 985 | } else if($this->envFileExists() && $this->DeployConfig) { |
986 | 986 | file_put_contents($this->getConfigFilename(), $this->DeployConfig); |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | if(!$this->Filename) { |
1048 | 1048 | return ''; |
1049 | 1049 | } |
1050 | - return $this->DNData()->getEnvironmentDir().'/'.$this->Project()->Name.'/'.$this->Filename; |
|
1050 | + return $this->DNData()->getEnvironmentDir() . '/' . $this->Project()->Name . '/' . $this->Filename; |
|
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | /** |
@@ -1126,10 +1126,10 @@ discard block |
||
1126 | 1126 | $filter = isset($config->PipelineConfig->FilteredCommits) |
1127 | 1127 | ? $config->PipelineConfig->FilteredCommits |
1128 | 1128 | : null; |
1129 | - if (empty($filter)) return null; |
|
1129 | + if(empty($filter)) return null; |
|
1130 | 1130 | |
1131 | 1131 | // Create and execute filter |
1132 | - if (!class_exists($filter)) throw new Exception(sprintf("Class %s does not exist", $filter)); |
|
1132 | + if(!class_exists($filter)) throw new Exception(sprintf("Class %s does not exist", $filter)); |
|
1133 | 1133 | $commitClass = $filter::create(); |
1134 | 1134 | // setup the environment to check for commits |
1135 | 1135 | $commitClass->env = $dependsOnEnv; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | public function getCommits() { |
46 | - if (!isset($this->env)) { |
|
46 | + if(!isset($this->env)) { |
|
47 | 47 | $this->environmentNotSetException(); |
48 | 48 | } |
49 | 49 | $successfulCommits = |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | public function getLatestCommit() { |
57 | - if (!isset($this->env)) { |
|
57 | + if(!isset($this->env)) { |
|
58 | 58 | $this->environmentNotSetException(); |
59 | 59 | } |
60 | 60 | $commits = $this->getCommits(); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @return array |
239 | 239 | */ |
240 | 240 | public function getProcessEnv() { |
241 | - if (file_exists($this->getPrivateKeyPath())) { |
|
241 | + if(file_exists($this->getPrivateKeyPath())) { |
|
242 | 242 | // Key-pair is available, use it. |
243 | 243 | $processEnv = array( |
244 | 244 | 'IDENT_KEY' => $this->getPrivateKeyPath(), |
@@ -324,21 +324,21 @@ discard block |
||
324 | 324 | * Returns a map of envrionment name to build name |
325 | 325 | */ |
326 | 326 | public function currentBuilds() { |
327 | - if(!isset(self::$relation_cache['currentBuilds.'.$this->ID])) { |
|
327 | + if(!isset(self::$relation_cache['currentBuilds.' . $this->ID])) { |
|
328 | 328 | $currentBuilds = array(); |
329 | 329 | foreach($this->Environments() as $env) { |
330 | 330 | $currentBuilds[$env->Name] = $env->CurrentBuild(); |
331 | 331 | } |
332 | - self::$relation_cache['currentBuilds.'.$this->ID] = $currentBuilds; |
|
332 | + self::$relation_cache['currentBuilds.' . $this->ID] = $currentBuilds; |
|
333 | 333 | } |
334 | - return self::$relation_cache['currentBuilds.'.$this->ID]; |
|
334 | + return self::$relation_cache['currentBuilds.' . $this->ID]; |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** |
338 | 338 | * |
339 | 339 | * @return string |
340 | 340 | */ |
341 | - public function Link($action='') { |
|
341 | + public function Link($action = '') { |
|
342 | 342 | return Controller::join_links("naut", "project", $this->Name, $action); |
343 | 343 | } |
344 | 344 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @return boolean |
418 | 418 | */ |
419 | 419 | public function projectFolderExists() { |
420 | - if(file_exists($this->DNData()->getEnvironmentDir().'/'.$this->Name)) { |
|
420 | + if(file_exists($this->DNData()->getEnvironmentDir() . '/' . $this->Name)) { |
|
421 | 421 | return true; |
422 | 422 | } |
423 | 423 | return false; |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @return bool |
429 | 429 | */ |
430 | 430 | public function repoExists() { |
431 | - return file_exists(DEPLOYNAUT_LOCAL_VCS_PATH . '/' . $this->Name.'/HEAD'); |
|
431 | + return file_exists(DEPLOYNAUT_LOCAL_VCS_PATH . '/' . $this->Name . '/HEAD'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | protected function checkProjectPath() { |
469 | 469 | // Create the project capistrano folder |
470 | 470 | if($this->CreateEnvFolder && !file_exists($this->getProjectFolderPath())) { |
471 | - mkdir($this->DNData()->getEnvironmentDir().'/'.$this->Name); |
|
471 | + mkdir($this->DNData()->getEnvironmentDir() . '/' . $this->Name); |
|
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | */ |
478 | 478 | protected function checkCVSPath() { |
479 | 479 | $changedFields = $this->getChangedFields(true, 2); |
480 | - if (!$this->CVSPath) { |
|
480 | + if(!$this->CVSPath) { |
|
481 | 481 | return; |
482 | 482 | } |
483 | - if (isset($changedFields['CVSPath']) || isset($changedFields['Name'])) { |
|
483 | + if(isset($changedFields['CVSPath']) || isset($changedFields['Name'])) { |
|
484 | 484 | $this->cloneRepo(); |
485 | 485 | } |
486 | 486 | } |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | public function getPublicKey() { |
512 | 512 | $key = $this->getPublicKeyPath(); |
513 | 513 | |
514 | - if (file_exists($key)) { |
|
514 | + if(file_exists($key)) { |
|
515 | 515 | return file_get_contents($key); |
516 | 516 | } |
517 | 517 | } |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | */ |
593 | 593 | public function getRepositoryURL() { |
594 | 594 | $showUrl = Config::inst()->get($this->class, 'show_repository_url'); |
595 | - if ($showUrl) { |
|
595 | + if($showUrl) { |
|
596 | 596 | return $this->CVSPath; |
597 | 597 | } |
598 | 598 | } |
@@ -602,6 +602,6 @@ discard block |
||
602 | 602 | * @return string |
603 | 603 | */ |
604 | 604 | protected function getProjectFolderPath() { |
605 | - return $this->DNData()->getEnvironmentDir().'/'.$this->Name; |
|
605 | + return $this->DNData()->getEnvironmentDir() . '/' . $this->Name; |
|
606 | 606 | } |
607 | 607 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | public static $cache = array(); |
8 | 8 | |
9 | 9 | public static function getIncludingBranches($commit) { |
10 | - $cacheKey = 'getIncludingBranches-' .$commit->getRepository()->getPath() . '-' . $commit->gethash(); |
|
10 | + $cacheKey = 'getIncludingBranches-' . $commit->getRepository()->getPath() . '-' . $commit->gethash(); |
|
11 | 11 | if(!isset(self::$cache[$cacheKey])) { |
12 | 12 | self::$cache[$cacheKey] = $commit->getIncludingBranches(); |
13 | 13 | } |