From 177a524475bd8a93fe0eb42601b3a443a970611a Mon Sep 17 00:00:00 2001 From: Gabriel Baker Date: Tue, 14 May 2013 18:16:33 +0100 Subject: [PATCH] optional symlink defaulting to cp --- PHPCI/Builder.php | 30 +++++++-- PHPCI/Model/Base/ProjectBase.php | 108 +++++++++++++------------------ 2 files changed, 71 insertions(+), 67 deletions(-) diff --git a/PHPCI/Builder.php b/PHPCI/Builder.php index ec47b479..eb0ffba0 100644 --- a/PHPCI/Builder.php +++ b/PHPCI/Builder.php @@ -133,15 +133,37 @@ class Builder case 'local': $reference = $this->build->getProject()->getReference(); $this->buildPath = $this->ciDir . 'build/' . $buildId; + // don't want no slash on the end if(substr($reference, -1) == '/') { - $reference = substr($reference, 0, -1) + $reference = substr($reference, 0, -1); } - if(is_link($this->buildPath) && is_file($this->buildPath)) { + + if(!is_file($reference . '/phpci.yml')) + { + $this->logFailure('Project does not contain a phpci.yml file.'); + return false; + } + + $this->config = yaml_parse_file($reference . '/phpci.yml'); + + if ( array_key_exists('prebuild', $this->config) + && is_array($this->config['prebuild']) + && array_key_exists('preferSymlink', $this->config['prebuild']) + && true === $this->config['prebuild']['preferSymlink'] ) { + + if(is_link($this->buildPath) && is_file($this->buildPath)) { + unlink($this->buildPath); + } + + symlink($reference, $this->buildPath); + } } else { - symlink($reference, $this->buildPath); + $this->executeCommand( + sprintf("cp -Rf %s %s/", $reference, $this->buildPath) + ); } - $this->buildPath .= '/'; + break; default: mkdir($this->buildPath, 0777, true); diff --git a/PHPCI/Model/Base/ProjectBase.php b/PHPCI/Model/Base/ProjectBase.php index c60649fc..cb8ff9a6 100644 --- a/PHPCI/Model/Base/ProjectBase.php +++ b/PHPCI/Model/Base/ProjectBase.php @@ -16,79 +16,61 @@ class ProjectBase extends Model protected $_tableName = 'project'; protected $_modelName = 'Project'; protected $_data = array( - 'id' => null, - 'title' => null, - 'reference' => null, - 'git_key' => null, - 'type' => null, - ); + 'id' => null, + 'title' => null, + 'reference' => null, + 'git_key' => null, + 'type' => null, + ); protected $_getters = array( - 'id' => 'getId', - 'title' => 'getTitle', - 'reference' => 'getReference', - 'git_key' => 'getGitKey', - 'type' => 'getType', - - - ); + 'id' => 'getId', + 'title' => 'getTitle', + 'reference' => 'getReference', + 'git_key' => 'getGitKey', + 'type' => 'getType', + ); protected $_setters = array( - 'id' => 'setId', - 'title' => 'setTitle', - 'reference' => 'setReference', - 'git_key' => 'setGitKey', - 'type' => 'setType', + 'id' => 'setId', + 'title' => 'setTitle', + 'reference' => 'setReference', + 'git_key' => 'setGitKey', + 'type' => 'setType', + ); - ); public $columns = array( - 'id' => array( - 'type' => 'int', - 'length' => '11', + 'id' => array( + 'type' => 'int', + 'length' => '11', - 'primary_key' => true, - 'auto_increment' => true, + 'primary_key' => true, + 'auto_increment' => true, - ), - 'title' => array( - 'type' => 'varchar', - 'length' => '250', + ), + 'title' => array( + 'type' => 'varchar', + 'length' => '250', + ), + 'reference' => array( + 'type' => 'varchar', + 'length' => '250', + ), + 'git_key' => array( + 'type' => 'text', + 'length' => '', + ), + 'type' => array( + 'type' => 'varchar', + 'length' => '50', + ), + ); - - - - ), - 'reference' => array( - 'type' => 'varchar', - 'length' => '250', - - - - - ), - 'git_key' => array( - 'type' => 'text', - 'length' => '', - - - - - ), - 'type' => array( - 'type' => 'varchar', - 'length' => '50', - - - - - ), - ); public $indexes = array( - 'PRIMARY' => array('unique' => true, 'columns' => 'id'), - ); + 'PRIMARY' => array('unique' => true, 'columns' => 'id'), + ); + public $foreignKeys = array( - ); - - + ); public function getId() {