Feature: Choose branch
This commit is contained in:
parent
8469628f7d
commit
5d360413bd
|
@ -87,7 +87,7 @@ class PollCommand extends Command
|
|||
$build->setProjectId($project->getId());
|
||||
$build->setCommitId($last_commit);
|
||||
$build->setStatus(Build::STATUS_NEW);
|
||||
$build->setBranch($project->getType() === 'hg' ? 'default' : 'master');
|
||||
$build->setBranch($project->getBranch());
|
||||
$build->setCreated(new \DateTime());
|
||||
if (!empty($last_committer)) {
|
||||
$build->setCommitterEmail($last_committer);
|
||||
|
|
|
@ -85,7 +85,7 @@ class ProjectController extends \PHPCI\Controller
|
|||
$build->setProjectId($projectId);
|
||||
$build->setCommitId('Manual');
|
||||
$build->setStatus(Build::STATUS_NEW);
|
||||
$build->setBranch($project->getType() === 'hg' ? 'default' : 'master');
|
||||
$build->setBranch($project->getBranch());
|
||||
$build->setCreated(new \DateTime());
|
||||
$build->setCommitterEmail($_SESSION['user']->getEmail());
|
||||
|
||||
|
@ -312,6 +312,14 @@ class ProjectController extends \PHPCI\Controller
|
|||
$field->setContainerClass('form-group');
|
||||
$form->addField($field);
|
||||
|
||||
$field = new Form\Element\Text('branch');
|
||||
$field->setRequired(true);
|
||||
$field->setValidator($this->getReferenceValidator($values));
|
||||
$field->setLabel('Branch name');
|
||||
$field->setClass('form-control');
|
||||
$field->setContainerClass('form-group');
|
||||
$form->addField($field);
|
||||
|
||||
$field = new Form\Element\Text('title');
|
||||
$field->setRequired(true);
|
||||
$field->setLabel('Project Title');
|
||||
|
|
40
PHPCI/Migrations/20140611170618_choose_branch.php
Normal file
40
PHPCI/Migrations/20140611170618_choose_branch.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
class ChooseBranch extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* More information on this method is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-change-method
|
||||
*
|
||||
* Uncomment this method if you would like to use it.
|
||||
*
|
||||
public function change()
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Migrate Up.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$project = $this->table('project');
|
||||
$project->addColumn('branch', 'string', array(
|
||||
'after' => 'reference',
|
||||
'limit' => 250
|
||||
))->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate Down.
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$project = $this->table('project');
|
||||
$project->removeColumn('branch')->save();
|
||||
}
|
||||
}
|
|
@ -53,6 +53,7 @@ class ProjectBase extends Model
|
|||
'id' => 'getId',
|
||||
'title' => 'getTitle',
|
||||
'reference' => 'getReference',
|
||||
'branch' => 'getBranch',
|
||||
'ssh_private_key' => 'getSshPrivateKey',
|
||||
'ssh_public_key' => 'getSshPublicKey',
|
||||
'type' => 'getType',
|
||||
|
@ -72,6 +73,7 @@ class ProjectBase extends Model
|
|||
'id' => 'setId',
|
||||
'title' => 'setTitle',
|
||||
'reference' => 'setReference',
|
||||
'branch' => 'setBranch',
|
||||
'ssh_private_key' => 'setSshPrivateKey',
|
||||
'ssh_public_key' => 'setSshPublicKey',
|
||||
'type' => 'setType',
|
||||
|
@ -104,6 +106,11 @@ class ProjectBase extends Model
|
|||
'length' => 250,
|
||||
'default' => null,
|
||||
),
|
||||
'branch' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 250,
|
||||
'default' => null,
|
||||
),
|
||||
'ssh_private_key' => array(
|
||||
'type' => 'text',
|
||||
'nullable' => true,
|
||||
|
@ -192,6 +199,20 @@ class ProjectBase extends Model
|
|||
return $rtn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of Branch / branch.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBranch()
|
||||
{
|
||||
if (empty($this->data['branch'])) {
|
||||
return $this->getType() === 'hg' ? 'default' : 'master';
|
||||
} else {
|
||||
return $this->data['branch'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of SshPrivateKey / ssh_private_key.
|
||||
*
|
||||
|
@ -336,6 +357,25 @@ class ProjectBase extends Model
|
|||
$this->_setModified('reference');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of Branch / branch.
|
||||
*
|
||||
* Must not be null.
|
||||
* @param $value string
|
||||
*/
|
||||
public function setBranch($value)
|
||||
{
|
||||
$this->_validateString('Branch', $value);
|
||||
|
||||
if ($this->data['branch'] === $value) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->data['branch'] = $value;
|
||||
|
||||
$this->_setModified('branch');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of SshPrivateKey / ssh_private_key.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue