Fixes for project type (git, github, gogs etc.). Issue #162.

This commit is contained in:
Dmitry Khomutov 2018-03-08 15:54:19 +07:00
commit f4ecb0e1e7
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
17 changed files with 63 additions and 63 deletions

View file

@ -427,20 +427,20 @@ class ProjectController extends PHPCensor\Controller
$form->addField(new Form\Element\Hidden('pubkey'));
$options = [
'choose' => Lang::get('select_repository_type'),
'github' => 'GitHub',
'bitbucket' => 'Bitbucket (Git)',
'bitbuckethg' => 'Bitbucket (Hg)',
'gitlab' => 'GitLab',
'gogs' => 'Gogs',
'remote' => 'Git',
'local' => Lang::get('local'),
'hg' => 'Mercurial (Hg)',
'svn' => 'SVN',
'choose' => Lang::get('select_repository_type'),
'github' => 'GitHub',
'bitbucket' => 'Bitbucket (Git)',
'bitbucket-hg' => 'Bitbucket (Hg)',
'gitlab' => 'GitLab',
'gogs' => 'Gogs',
'git' => 'Git',
'local' => Lang::get('local'),
'hg' => 'Hg (Mercurial)',
'svn' => 'Svn (Subversion)',
];
$field = Form\Element\Select::create('type', Lang::get('where_hosted'), true);
$field->setPattern('^(github|bitbucket|bitbuckethg|gitlab|gogs|remote|local|hg|svn)');
$field->setPattern('^(github|bitbucket|bitbucket-hg|gitlab|gogs|git|local|hg|svn)');
$field->setOptions($options);
$field->setClass('form-control')->setContainerClass('form-group');
$form->addField($field);
@ -541,11 +541,11 @@ class ProjectController extends PHPCensor\Controller
$validators = [
'hg' => [
'regex' => '/^(ssh|https?):\/\//',
'message' => Lang::get('error_mercurial')
'message' => Lang::get('error_hg')
],
'remote' => [
'git' => [
'regex' => '/^(git|https?):\/\//',
'message' => Lang::get('error_remote')
'message' => Lang::get('error_git')
],
'gitlab' => [
'regex' => '`^(.*)@(.*):(.*)/(.*)\.git`',
@ -559,7 +559,7 @@ class ProjectController extends PHPCensor\Controller
'regex' => '/^[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-\.]+$/',
'message' => Lang::get('error_bitbucket')
],
'bitbuckethg' => [
'bitbucket-hg' => [
'regex' => '/^[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-\.]+$/',
'message' => Lang::get('error_bitbucket')
],

View file

@ -82,7 +82,7 @@ class WebhookController extends Controller
*/
public function bitbucket($projectId)
{
$project = $this->fetchProject($projectId, ['bitbucket', 'bitbuckethg', 'remote']);
$project = $this->fetchProject($projectId, ['bitbucket', 'bitbucket-hg', 'hg', 'git']);
// Support both old services and new webhooks
if ($payload = $this->getParam('payload')) {
@ -272,7 +272,7 @@ class WebhookController extends Controller
*/
public function git($projectId)
{
$project = $this->fetchProject($projectId, ['local', 'remote']);
$project = $this->fetchProject($projectId, ['local', 'git']);
$branch = $this->getParam('branch', $project->getBranch());
$commit = $this->getParam('commit');
$commitMessage = $this->getParam('message');
@ -294,7 +294,7 @@ class WebhookController extends Controller
*/
public function github($projectId)
{
$project = $this->fetchProject($projectId, ['github', 'remote']);
$project = $this->fetchProject($projectId, ['github', 'git']);
switch ($_SERVER['CONTENT_TYPE']) {
case 'application/json':
@ -475,7 +475,7 @@ class WebhookController extends Controller
*/
public function gitlab($projectId)
{
$project = $this->fetchProject($projectId, ['gitlab', 'remote']);
$project = $this->fetchProject($projectId, ['gitlab', 'git']);
$payloadString = file_get_contents("php://input");
$payload = json_decode($payloadString, true);
@ -568,7 +568,7 @@ class WebhookController extends Controller
*/
public function gogs($projectId)
{
$project = $this->fetchProject($projectId, ['gogs', 'remote']);
$project = $this->fetchProject($projectId, ['gogs', 'git']);
switch ($_SERVER['CONTENT_TYPE']) {
case 'application/json':
$payload = json_decode(file_get_contents('php://input'), true);