diff --git a/resources/sql/patches/092.dropgithubnotification.sql b/resources/sql/patches/092.dropgithubnotification.sql new file mode 100644 index 0000000000..f197fb2b18 --- /dev/null +++ b/resources/sql/patches/092.dropgithubnotification.sql @@ -0,0 +1 @@ +DROP TABLE phabricator_repository.repository_githubnotification; \ No newline at end of file diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 7590abb228..a3313624e9 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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', diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index ae4c7bb907..aed6c09368 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -173,9 +173,6 @@ class AphrontDefaultApplicationConfiguration '/T(?P\d+)$' => 'ManiphestTaskDetailController', - '/github-post-receive/(?P\d+)/(?P[^/]+)/$' - => 'PhabricatorRepositoryGitHubPostReceiveController', - '/repository/' => array( '$' => 'PhabricatorRepositoryListController', 'create/$' => 'PhabricatorRepositoryCreateController', diff --git a/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php b/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php index ec61a67bce..d29a08dcce 100644 --- a/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php +++ b/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php @@ -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( - '

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.

') - ->appendChild( - '

If things are working '. - 'properly, push notifications should appear below once you make some '. - 'commits.

') - ->appendChild( - id(new AphrontFormTextControl()) - ->setLabel('URL') - ->setCaption('Set this as a GitHub "Post-Receive URL".') - ->setValue($post_uri)) - ->appendChild('

') - ->appendChild('

Recent Commit Notifications

'); - - $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', - )); - } } diff --git a/src/applications/repository/controller/edit/__init__.php b/src/applications/repository/controller/edit/__init__.php index e3f019c481..a63242ea46 100644 --- a/src/applications/repository/controller/edit/__init__.php +++ b/src/applications/repository/controller/edit/__init__.php @@ -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'); diff --git a/src/applications/repository/controller/github-post-receive/PhabricatorRepositoryGitHubPostReceiveController.php b/src/applications/repository/controller/github-post-receive/PhabricatorRepositoryGitHubPostReceiveController.php deleted file mode 100644 index d75dda55cf..0000000000 --- a/src/applications/repository/controller/github-post-receive/PhabricatorRepositoryGitHubPostReceiveController.php +++ /dev/null @@ -1,73 +0,0 @@ -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'); - } - -} diff --git a/src/applications/repository/controller/github-post-receive/__init__.php b/src/applications/repository/controller/github-post-receive/__init__.php deleted file mode 100644 index 3b78ddc513..0000000000 --- a/src/applications/repository/controller/github-post-receive/__init__.php +++ /dev/null @@ -1,20 +0,0 @@ -