Merge pull request #85 from sanpii/remote

Allow arbitrary repository URL
This commit is contained in:
Dan Cryer 2013-06-25 04:32:25 -07:00
commit b767da324a
3 changed files with 15 additions and 3 deletions

View file

@ -28,6 +28,9 @@ class BuildFactory
{
switch($base->getProject()->getType())
{
case 'remote':
$type = 'RemoteGitBuild';
break;
case 'local':
$type = 'LocalBuild';
break;

View file

@ -252,12 +252,13 @@ class ProjectController extends \PHPCI\Controller
'choose' => 'Select repository type...',
'github' => 'Github',
'bitbucket' => 'Bitbucket',
'remote' => 'Remote URL',
'local' => 'Local Path'
);
$field = new Form\Element\Select('type');
$field->setRequired(true);
$field->setPattern('^(github|bitbucket|local)');
$field->setPattern('^(github|bitbucket|remote|local)');
$field->setOptions($options);
$field->setLabel('Where is your project hosted?');
$field->setClass('span4');
@ -275,6 +276,11 @@ class ProjectController extends \PHPCI\Controller
$type = $values['type'];
switch($type) {
case 'remote':
if (!preg_match('/^(git|https?):\/\//', $val)) {
throw new \Exception('Repository URL must be start with git://, http:// or https://.');
}
break;
case 'local':
if (!is_dir($val)) {
throw new \Exception('The path you specified does not exist.');

View file

@ -19,12 +19,15 @@ use Symfony\Component\Yaml\Parser as YamlParser;
* @package PHPCI
* @subpackage Core
*/
abstract class RemoteGitBuild extends Build
class RemoteGitBuild extends Build
{
/**
* Get the URL to be used to clone this remote repository.
*/
abstract protected function getCloneUrl();
protected function getCloneUrl()
{
return $this->getProject()->getReference();
}
/**
* Create a working copy by cloning, copying, or similar.