1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 16:30:59 +01:00

Remove support for GitHub post-receive notifications

Summary:
  - These never actually did anything.
  - I don't even really remember why I built them, maybe the Open Source team
was pushing for more GitHub integration or something? I really have no idea.
  - Anyway, repository tailers do everything these could do (and much more).

Test Plan:
  - Ran tailers off GitHub for many months without needing post-receive hooks.
  - Grepped for relevant strings, couldn't find any references.
  - Used "Repository" edit interface for a Git repository.

Reviewers: btrahan, jungejason

Reviewed By: jungejason

CC: aran, jungejason

Maniphest Tasks: T706

Differential Revision: https://secure.phabricator.com/D1273
This commit is contained in:
epriestley 2011-12-22 15:24:20 -08:00
parent f4f8ea0b34
commit bdbe9df65e
9 changed files with 1 additions and 242 deletions

View file

@ -0,0 +1 @@
DROP TABLE phabricator_repository.repository_githubnotification;

View file

@ -626,8 +626,6 @@ phutil_register_library_map(array(
'PhabricatorRepositoryGitCommitDiscoveryDaemonTestCase' => 'applications/repository/daemon/commitdiscovery/git/__tests__',
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/git',
'PhabricatorRepositoryGitFetchDaemon' => 'applications/repository/daemon/gitfetch',
'PhabricatorRepositoryGitHubNotification' => 'applications/repository/storage/githubnotification',
'PhabricatorRepositoryGitHubPostReceiveController' => 'applications/repository/controller/github-post-receive',
'PhabricatorRepositoryListController' => 'applications/repository/controller/list',
'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/mercurial',
'PhabricatorRepositoryMercurialCommitDiscoveryDaemon' => 'applications/repository/daemon/commitdiscovery/mercurial',
@ -1272,8 +1270,6 @@ phutil_register_library_map(array(
'PhabricatorRepositoryGitCommitDiscoveryDaemonTestCase' => 'PhabricatorTestCase',
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
'PhabricatorRepositoryGitFetchDaemon' => 'PhabricatorRepositoryPullLocalDaemon',
'PhabricatorRepositoryGitHubNotification' => 'PhabricatorRepositoryDAO',
'PhabricatorRepositoryGitHubPostReceiveController' => 'PhabricatorRepositoryController',
'PhabricatorRepositoryListController' => 'PhabricatorRepositoryController',
'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',
'PhabricatorRepositoryMercurialCommitDiscoveryDaemon' => 'PhabricatorRepositoryCommitDiscoveryDaemon',

View file

@ -173,9 +173,6 @@ class AphrontDefaultApplicationConfiguration
'/T(?P<id>\d+)$' => 'ManiphestTaskDetailController',
'/github-post-receive/(?P<id>\d+)/(?P<token>[^/]+)/$'
=> 'PhabricatorRepositoryGitHubPostReceiveController',
'/repository/' => array(
'$' => 'PhabricatorRepositoryListController',
'create/$' => 'PhabricatorRepositoryCreateController',

View file

@ -43,20 +43,6 @@ class PhabricatorRepositoryEditController
'tracking' => 'Tracking',
);
$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);
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$repository->save();
unset($unguarded);
}
$views['github'] = 'GitHub';
}
$this->repository = $repository;
if (!isset($views[$this->view])) {
@ -85,8 +71,6 @@ class PhabricatorRepositoryEditController
return $this->processBasicRequest();
case 'tracking':
return $this->processTrackingRequest();
case 'github':
return $this->processGithubRequest();
default:
throw new Exception("Unknown view.");
}
@ -675,86 +659,4 @@ class PhabricatorRepositoryEditController
));
}
private function processGithubRequest() {
$request = $this->getRequest();
$repository = $this->repository;
$repository_id = $repository->getID();
$viewer = $this->getRequest()->getUser();
$token = $repository->getDetail('github-token');
$path = '/github-post-receive/'.$repository_id.'/'.$token.'/';
$post_uri = PhabricatorEnv::getURI($path);
$gitform = new AphrontFormLayoutView();
$gitform
->setBackgroundShading(true)
->setPadded(true)
->appendChild(
'<p class="aphront-form-instructions">You can configure GitHub to '.
'notify Phabricator after changes are pushed. Log into GitHub, go '.
'to "Admin" &rarr; "Service Hooks" &rarr; "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_datetime($notification->getDateCreated(), $viewer),
$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);
$nav = $this->sideNav;
$nav->appendChild($github);
return $this->buildStandardPageResponse(
$nav,
array(
'title' => 'Repository Github Integration',
));
}
}

View file

@ -8,14 +8,10 @@
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'aphront/writeguard');
phutil_require_module('phabricator', 'applications/differential/constants/revisioncontrolsystem');
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
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('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/password');
phutil_require_module('phabricator', 'view/form/control/select');
@ -24,12 +20,9 @@ phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/form/control/text');
phutil_require_module('phabricator', 'view/form/control/textarea');
phutil_require_module('phabricator', 'view/form/error');
phutil_require_module('phabricator', 'view/form/layout');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phabricator', 'view/layout/sidenav');
phutil_require_module('phabricator', 'view/utils');
phutil_require_module('phutil', 'filesystem');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'symbols');
phutil_require_module('phutil', 'utils');

View file

@ -1,73 +0,0 @@
<?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 shouldRequireAdmin() {
return false;
}
public function shouldRequireLogin() {
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!");
}
// GitHub POSTs here and doesn't do CSRF.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$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');
}
}

View file

@ -1,20 +0,0 @@
<?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', 'aphront/writeguard');
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');

View file

@ -1,25 +0,0 @@
<?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;
}

View file

@ -1,12 +0,0 @@
<?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');