mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Rough cut of Repositories and GitHub post-receive hooks.
Summary: Test Plan: Reviewers: CC:
This commit is contained in:
parent
8784b5bd3b
commit
f55a30a288
18 changed files with 778 additions and 6 deletions
|
@ -222,6 +222,14 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPeopleProfileController' => 'applications/people/controller/profile',
|
||||
'PhabricatorRemarkupRuleDifferential' => 'infrastructure/markup/remarkup/markuprule/differential',
|
||||
'PhabricatorRemarkupRuleManiphest' => 'infrastructure/markup/remarkup/markuprule/maniphest',
|
||||
'PhabricatorRepository' => 'applications/repository/storage/repository',
|
||||
'PhabricatorRepositoryController' => 'applications/repository/controller/base',
|
||||
'PhabricatorRepositoryCreateController' => 'applications/repository/controller/create',
|
||||
'PhabricatorRepositoryDAO' => 'applications/repository/storage/base',
|
||||
'PhabricatorRepositoryEditController' => 'applications/repository/controller/edit',
|
||||
'PhabricatorRepositoryGitHubNotification' => 'applications/repository/storage/githubnotification',
|
||||
'PhabricatorRepositoryGitHubPostReceiveController' => 'applications/repository/controller/github-post-receive',
|
||||
'PhabricatorRepositoryListController' => 'applications/repository/controller/list',
|
||||
'PhabricatorStandardPageView' => 'view/page/standard',
|
||||
'PhabricatorTypeaheadCommonDatasourceController' => 'applications/typeahead/controller/common',
|
||||
'PhabricatorTypeaheadDatasourceController' => 'applications/typeahead/controller/base',
|
||||
|
@ -421,6 +429,14 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController',
|
||||
'PhabricatorRemarkupRuleDifferential' => 'PhutilRemarkupRule',
|
||||
'PhabricatorRemarkupRuleManiphest' => 'PhutilRemarkupRule',
|
||||
'PhabricatorRepository' => 'PhabricatorRepositoryDAO',
|
||||
'PhabricatorRepositoryController' => 'PhabricatorController',
|
||||
'PhabricatorRepositoryCreateController' => 'PhabricatorController',
|
||||
'PhabricatorRepositoryDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorRepositoryEditController' => 'PhabricatorController',
|
||||
'PhabricatorRepositoryGitHubNotification' => 'PhabricatorRepositoryDAO',
|
||||
'PhabricatorRepositoryGitHubPostReceiveController' => 'PhabricatorRepositoryController',
|
||||
'PhabricatorRepositoryListController' => 'PhabricatorController',
|
||||
'PhabricatorStandardPageView' => 'AphrontPageView',
|
||||
'PhabricatorTypeaheadCommonDatasourceController' => 'PhabricatorTypeaheadDatasourceController',
|
||||
'PhabricatorTypeaheadDatasourceController' => 'PhabricatorController',
|
||||
|
|
|
@ -28,12 +28,6 @@ class AphrontDefaultApplicationConfiguration
|
|||
|
||||
public function getURIMap() {
|
||||
return array(
|
||||
'/repository/' => array(
|
||||
'$' => 'RepositoryListController',
|
||||
'new/$' => 'RepositoryEditController',
|
||||
'edit/(?P<id>\d+)/$' => 'RepositoryEditController',
|
||||
'delete/(?P<id>\d+)/$' => 'RepositoryDeleteController',
|
||||
),
|
||||
'/' => array(
|
||||
'$' => 'PhabricatorDirectoryMainController',
|
||||
),
|
||||
|
@ -152,6 +146,15 @@ class AphrontDefaultApplicationConfiguration
|
|||
),
|
||||
|
||||
'/T(?P<id>\d+)$' => 'ManiphestTaskDetailController',
|
||||
|
||||
'/github-post-receive/(?P<id>\d+)/(?P<token>[^/]+)/$'
|
||||
=> 'PhabricatorRepositoryGitHubPostReceiveController',
|
||||
'/repository/' => array(
|
||||
'$' => 'PhabricatorRepositoryListController',
|
||||
'create/$' => 'PhabricatorRepositoryCreateController',
|
||||
'edit/(?P<id>\d+)/$' => 'PhabricatorRepositoryEditController',
|
||||
'delete/(?P<id>\d+)/$' => 'PhabricatorRepositoryDeleteController',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
abstract class PhabricatorRepositoryController extends PhabricatorController {
|
||||
|
||||
public function buildStandardPageResponse($view, array $data) {
|
||||
$page = $this->buildStandardPageView();
|
||||
|
||||
$page->setApplicationName('Repositories');
|
||||
$page->setBaseURI('/repository/');
|
||||
$page->setTitle(idx($data, 'title'));
|
||||
$page->setGlyph("rX");
|
||||
$page->appendChild($view);
|
||||
|
||||
$response = new AphrontWebpageResponse();
|
||||
return $response->setContent($page->render());
|
||||
}
|
||||
|
||||
}
|
15
src/applications/repository/controller/base/__init__.php
Normal file
15
src/applications/repository/controller/base/__init__.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/webpage');
|
||||
phutil_require_module('phabricator', 'applications/base/controller/base');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryController.php');
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorRepositoryCreateController extends PhabricatorController {
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$e_name = true;
|
||||
$e_callsign = true;
|
||||
|
||||
$repository = new PhabricatorRepository();
|
||||
|
||||
$type_map = array(
|
||||
'svn' => 'Subversion',
|
||||
'git' => 'Git',
|
||||
);
|
||||
$errors = array();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
|
||||
$repository->setName($request->getStr('name'));
|
||||
$repository->setCallsign($request->getStr('callsign'));
|
||||
$repository->setVersionControlSystem($request->getStr('type'));
|
||||
|
||||
if (!strlen($repository->getName())) {
|
||||
$e_name = 'Required';
|
||||
$errors[] = 'Repository name is required.';
|
||||
} else {
|
||||
$e_name = null;
|
||||
}
|
||||
|
||||
if (!strlen($repository->getCallsign())) {
|
||||
$e_callsign = 'Required';
|
||||
$errors[] = 'Callsign is required.';
|
||||
} else if (!preg_match('/^[A-Z]+$/', $repository->getCallsign())) {
|
||||
$e_callsign = 'Invalid';
|
||||
$errors[] = 'Callsign must be ALL UPPERCASE LETTERS.';
|
||||
} else {
|
||||
$e_callsign = null;
|
||||
}
|
||||
|
||||
if (empty($type_map[$repository->getVersionControlSystem()])) {
|
||||
$errors[] = 'Invalid version control system.';
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
try {
|
||||
$repository->save();
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/repository/edit/'.$repository->getID().'/');
|
||||
|
||||
} catch (PhabricatorQueryDuplicateKeyException $ex) {
|
||||
if ($ex->getDuplicateKey() == 'callsign') {
|
||||
$e_callsign = 'Duplicate';
|
||||
$errors[] = 'Callsign must be unique. Another repository already '.
|
||||
'uses that callsign.';
|
||||
} else {
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$error_view = null;
|
||||
if ($errors) {
|
||||
$error_view = new AphrontErrorView();
|
||||
$error_view->setErrors($errors);
|
||||
$error_view->setTitle('Form Errors');
|
||||
}
|
||||
|
||||
|
||||
$form = new AphrontFormView();
|
||||
$form
|
||||
->setUser($user)
|
||||
->setAction('/repository/create/')
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Name')
|
||||
->setName('name')
|
||||
->setValue($repository->getName())
|
||||
->setError($e_name)
|
||||
->setCaption('Human-readable repository name.'))
|
||||
->appendChild(
|
||||
'<p class="aphront-form-instructions">Select a "Callsign" — a '.
|
||||
'short, uppercase string to identify revisions in this repository. If '.
|
||||
'you choose "EX", revisions in this repository will be identified '.
|
||||
'with the prefix "rEX".</p>')
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Callsign')
|
||||
->setName('callsign')
|
||||
->setValue($repository->getCallsign())
|
||||
->setError($e_callsign)
|
||||
->setCaption(
|
||||
'Short, UPPERCASE identifier. Once set, it can not be changed.'))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel('Type')
|
||||
->setName('type')
|
||||
->setOptions($type_map)
|
||||
->setValue($repository->getVersionControlSystem()))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue('Create Repository')
|
||||
->addCancelButton('/repository/'));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader('Create Repository');
|
||||
$panel->appendChild($form);
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
array(
|
||||
$error_view,
|
||||
$panel,
|
||||
),
|
||||
array(
|
||||
'title' => 'Create Repository',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
20
src/applications/repository/controller/create/__init__.php
Normal file
20
src/applications/repository/controller/create/__init__.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/base/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
||||
phutil_require_module('phabricator', 'view/form/base');
|
||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||
phutil_require_module('phabricator', 'view/form/error');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryCreateController.php');
|
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorRepositoryEditController extends PhabricatorController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = idx($data, 'id');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$repository = id(new PhabricatorRepository())->load($this->id);
|
||||
if (!$repository) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$vcs = $repository->getVersionControlSystem();
|
||||
if ($vcs == DifferentialRevisionControlSystem::GIT) {
|
||||
if (!$repository->getDetail('github-token')) {
|
||||
$token = substr(base64_encode(Filesystem::readRandomBytes(8)), 0, 8);
|
||||
$repository->setDetail('github-token', $token);
|
||||
$repository->save();
|
||||
}
|
||||
}
|
||||
|
||||
$e_name = true;
|
||||
|
||||
$type_map = array(
|
||||
'svn' => 'Subversion',
|
||||
'git' => 'Git',
|
||||
);
|
||||
$errors = array();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$repository->setName($request->getStr('name'));
|
||||
|
||||
if (!strlen($repository->getName())) {
|
||||
$e_name = 'Required';
|
||||
$errors[] = 'Repository name is required.';
|
||||
} else {
|
||||
$e_name = null;
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
$repository->save();
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/repository/');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$error_view = null;
|
||||
if ($errors) {
|
||||
$error_view = new AphrontErrorView();
|
||||
$error_view->setErrors($errors);
|
||||
$error_view->setTitle('Form Errors');
|
||||
}
|
||||
|
||||
|
||||
$form = new AphrontFormView();
|
||||
$form
|
||||
->setUser($user)
|
||||
->setAction('/repository/edit/'.$repository->getID().'/')
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Name')
|
||||
->setName('name')
|
||||
->setValue($repository->getName())
|
||||
->setError($e_name)
|
||||
->setCaption('Human-readable repository name.'))
|
||||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
->setLabel('Callsign')
|
||||
->setName('callsign')
|
||||
->setValue($repository->getCallsign()))
|
||||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
->setLabel('Type')
|
||||
->setName('type')
|
||||
->setValue($repository->getVersionControlSystem()));
|
||||
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue('Save')
|
||||
->addCancelButton('/repository/'));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader('Edit Repository');
|
||||
$panel->appendChild($form);
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||
|
||||
$phid = $repository->getID();
|
||||
$token = $repository->getDetail('github-token');
|
||||
$path = '/github-post-receive/'.$phid.'/'.$token.'/';
|
||||
$post_uri = PhabricatorEnv::getURI($path);
|
||||
|
||||
$gitform = new AphrontFormView();
|
||||
$gitform
|
||||
->setUser($user)
|
||||
->setAction('/repository/edit/'.$repository->getID().'/')
|
||||
->appendChild(
|
||||
'<p class="aphront-form-instructions">You can configure GitHub to '.
|
||||
'notify Phabricator after changes are pushed. Log into GitHub, go '.
|
||||
'to "Admin" → "Service Hooks" → "Post-Receive URLs", and '.
|
||||
'add this URL to the list. Obviously, this will only work if your '.
|
||||
'Phabricator installation is accessible from the internet.</p>')
|
||||
->appendChild(
|
||||
'<p class="aphront-form-instructions"> If things are working '.
|
||||
'properly, push notifications should appear below once you make some '.
|
||||
'commits.</p>')
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('URL')
|
||||
->setCaption('Set this as a GitHub "Post-Receive URL".')
|
||||
->setValue($post_uri))
|
||||
->appendChild('<br /><br />')
|
||||
->appendChild('<h1>Recent Commit Notifications</h1>');
|
||||
|
||||
$notifications = id(new PhabricatorRepositoryGitHubNotification())
|
||||
->loadAllWhere(
|
||||
'repositoryPHID = %s ORDER BY id DESC limit 10',
|
||||
$repository->getPHID());
|
||||
|
||||
$rows = array();
|
||||
foreach ($notifications as $notification) {
|
||||
$rows[] = array(
|
||||
phutil_escape_html($notification->getRemoteAddress()),
|
||||
phabricator_format_timestamp($notification->getDateCreated()),
|
||||
$notification->getPayload()
|
||||
? phutil_escape_html(substr($notification->getPayload(), 0, 32).'...')
|
||||
: 'Empty',
|
||||
);
|
||||
}
|
||||
|
||||
$notification_table = new AphrontTableView($rows);
|
||||
$notification_table->setHeaders(
|
||||
array(
|
||||
'Remote Address',
|
||||
'Received',
|
||||
'Payload',
|
||||
));
|
||||
$notification_table->setColumnClasses(
|
||||
array(
|
||||
null,
|
||||
null,
|
||||
'wide',
|
||||
));
|
||||
$notification_table->setNoDataString(
|
||||
'Phabricator has not yet received any commit notifications for this '.
|
||||
'repository from GitHub.');
|
||||
|
||||
$gitform->appendChild($notification_table);
|
||||
|
||||
$github = new AphrontPanelView();
|
||||
$github->setHeader('GitHub Integration');
|
||||
$github->appendChild($gitform);
|
||||
$github->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
array(
|
||||
$error_view,
|
||||
$panel,
|
||||
$github,
|
||||
),
|
||||
array(
|
||||
'title' => 'Edit Repository',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
29
src/applications/repository/controller/edit/__init__.php
Normal file
29
src/applications/repository/controller/edit/__init__.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/base/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/revisioncontrolsystem');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/githubnotification');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/form/base');
|
||||
phutil_require_module('phabricator', 'view/form/control/static');
|
||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||
phutil_require_module('phabricator', 'view/form/error');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
phutil_require_module('phabricator', 'view/utils');
|
||||
|
||||
phutil_require_module('phutil', 'filesystem');
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryEditController.php');
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
class PhabricatorRepositoryGitHubPostReceiveController
|
||||
extends PhabricatorRepositoryController {
|
||||
|
||||
public function shouldRequireAuthentication() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private $id;
|
||||
private $token;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
$this->token = $data['token'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
|
||||
$repo = id(new PhabricatorRepository())->load($this->id);
|
||||
if (!$repo) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
if ($repo->getDetail('github-token') != $this->token) {
|
||||
return new Aphront400Response();
|
||||
}
|
||||
|
||||
if (!$request->isHTTPPost()) {
|
||||
return id(new AphrontFileResponse())
|
||||
->setMimeType('text/plain')
|
||||
->setContent(
|
||||
"Put this URL in your GitHub configuration. Accessing it directly ".
|
||||
"won't do anything!");
|
||||
}
|
||||
|
||||
$notification = new PhabricatorRepositoryGitHubNotification();
|
||||
$notification->setRepositoryPHID($repo->getPHID());
|
||||
$notification->setRemoteAddress($_SERVER['REMOTE_ADDR']);
|
||||
$notification->setPayload($request->getStr('payload', ''));
|
||||
$notification->save();
|
||||
|
||||
return id(new AphrontFileResponse())
|
||||
->setMimeType('text/plain')
|
||||
->setContent('OK');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/400');
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'aphront/response/file');
|
||||
phutil_require_module('phabricator', 'applications/repository/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/githubnotification');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryGitHubPostReceiveController.php');
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorRepositoryListController extends PhabricatorController {
|
||||
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$repos = id(new PhabricatorRepository())->loadAll();
|
||||
|
||||
$rows = array();
|
||||
foreach ($repos as $repo) {
|
||||
$rows[] = array(
|
||||
phutil_escape_html($repo->getCallsign()),
|
||||
phutil_escape_html($repo->getName()),
|
||||
$repo->getVersionControlSystem(),
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'class' => 'button small grey',
|
||||
'href' => '/repository/edit/'.$repo->getID().'/',
|
||||
),
|
||||
'Edit'),
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'class' => 'button small grey',
|
||||
'href' => '/repository/delete/'.$repo->getID().'/',
|
||||
),
|
||||
'Delete'),
|
||||
);
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'Callsign',
|
||||
'Repository',
|
||||
'Type',
|
||||
'',
|
||||
''
|
||||
));
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
null,
|
||||
'wide',
|
||||
null,
|
||||
'action',
|
||||
'action',
|
||||
));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader('Repositories');
|
||||
$panel->setCreateButton('Create New Repository', '/repository/create/');
|
||||
$panel->appendChild($table);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$panel,
|
||||
array(
|
||||
'title' => 'Repository List',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
18
src/applications/repository/controller/list/__init__.php
Normal file
18
src/applications/repository/controller/list/__init__.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/base/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryListController.php');
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorRepositoryDAO extends PhabricatorLiskDAO {
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'repository';
|
||||
}
|
||||
|
||||
}
|
12
src/applications/repository/storage/base/__init__.php
Normal file
12
src/applications/repository/storage/base/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/base/storage/lisk');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryDAO.php');
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorRepositoryGitHubNotification extends PhabricatorRepositoryDAO {
|
||||
|
||||
protected $repositoryPHID;
|
||||
protected $remoteAddress;
|
||||
protected $payload;
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/base');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryGitHubNotification.php');
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
||||
|
||||
protected $phid;
|
||||
protected $name;
|
||||
protected $callsign;
|
||||
|
||||
protected $versionControlSystem;
|
||||
protected $details = array();
|
||||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_AUX_PHID => true,
|
||||
self::CONFIG_SERIALIZATION => array(
|
||||
'details' => self::SERIALIZATION_JSON,
|
||||
),
|
||||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID('REPO');
|
||||
}
|
||||
|
||||
public function getDetail($key, $default = null) {
|
||||
return idx($this->details, $key, $default);
|
||||
}
|
||||
|
||||
public function setDetail($key, $value) {
|
||||
$this->details[$key] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
15
src/applications/repository/storage/repository/__init__.php
Normal file
15
src/applications/repository/storage/repository/__init__.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/phid/storage/phid');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/base');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepository.php');
|
Loading…
Reference in a new issue