mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30:55 +01:00
Merge branch 'filebrowse'
This commit is contained in:
commit
0222756704
11 changed files with 274 additions and 1 deletions
|
@ -143,10 +143,14 @@ phutil_register_library_map(array(
|
||||||
'DifferentialSubscribeController' => 'applications/differential/controller/subscribe',
|
'DifferentialSubscribeController' => 'applications/differential/controller/subscribe',
|
||||||
'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus',
|
'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus',
|
||||||
'DiffusionBrowseController' => 'applications/diffusion/controller/browse',
|
'DiffusionBrowseController' => 'applications/diffusion/controller/browse',
|
||||||
|
'DiffusionBrowseFileController' => 'applications/diffusion/controller/file',
|
||||||
'DiffusionBrowseQuery' => 'applications/diffusion/query/browse/base',
|
'DiffusionBrowseQuery' => 'applications/diffusion/query/browse/base',
|
||||||
'DiffusionBrowseTableView' => 'applications/diffusion/view/browsetable',
|
'DiffusionBrowseTableView' => 'applications/diffusion/view/browsetable',
|
||||||
'DiffusionController' => 'applications/diffusion/controller/base',
|
'DiffusionController' => 'applications/diffusion/controller/base',
|
||||||
|
'DiffusionFileContent' => 'applications/diffusion/data/filecontent',
|
||||||
|
'DiffusionFileContentQuery' => 'applications/diffusion/query/filecontent/base',
|
||||||
'DiffusionGitBrowseQuery' => 'applications/diffusion/query/browse/git',
|
'DiffusionGitBrowseQuery' => 'applications/diffusion/query/browse/git',
|
||||||
|
'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/git',
|
||||||
'DiffusionHomeController' => 'applications/diffusion/controller/home',
|
'DiffusionHomeController' => 'applications/diffusion/controller/home',
|
||||||
'DiffusionRepositoryPath' => 'applications/diffusion/data/repositorypath',
|
'DiffusionRepositoryPath' => 'applications/diffusion/data/repositorypath',
|
||||||
'Javelin' => 'infrastructure/javelin/api',
|
'Javelin' => 'infrastructure/javelin/api',
|
||||||
|
@ -428,9 +432,11 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionViewController' => 'DifferentialController',
|
'DifferentialRevisionViewController' => 'DifferentialController',
|
||||||
'DifferentialSubscribeController' => 'DifferentialController',
|
'DifferentialSubscribeController' => 'DifferentialController',
|
||||||
'DiffusionBrowseController' => 'DiffusionController',
|
'DiffusionBrowseController' => 'DiffusionController',
|
||||||
|
'DiffusionBrowseFileController' => 'DiffusionController',
|
||||||
'DiffusionBrowseTableView' => 'AphrontView',
|
'DiffusionBrowseTableView' => 'AphrontView',
|
||||||
'DiffusionController' => 'PhabricatorController',
|
'DiffusionController' => 'PhabricatorController',
|
||||||
'DiffusionGitBrowseQuery' => 'DiffusionBrowseQuery',
|
'DiffusionGitBrowseQuery' => 'DiffusionBrowseQuery',
|
||||||
|
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
'DiffusionHomeController' => 'DiffusionController',
|
'DiffusionHomeController' => 'DiffusionController',
|
||||||
'ManiphestController' => 'PhabricatorController',
|
'ManiphestController' => 'PhabricatorController',
|
||||||
'ManiphestDAO' => 'PhabricatorLiskDAO',
|
'ManiphestDAO' => 'PhabricatorLiskDAO',
|
||||||
|
|
|
@ -66,7 +66,11 @@ class DiffusionBrowseController extends DiffusionController {
|
||||||
$severity = AphrontErrorView::SEVERITY_WARNING;
|
$severity = AphrontErrorView::SEVERITY_WARNING;
|
||||||
break;
|
break;
|
||||||
case DiffusionBrowseQuery::REASON_IS_FILE:
|
case DiffusionBrowseQuery::REASON_IS_FILE:
|
||||||
throw new Exception("TODO: implement this");
|
$controller = new DiffusionBrowseFileController($this->getRequest());
|
||||||
|
$controller->setRepository($repository);
|
||||||
|
$controller->setPath($this->path);
|
||||||
|
$controller->setCommit($this->commit);
|
||||||
|
return $this->delegateToController($controller);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception("Unknown failure reason!");
|
throw new Exception("Unknown failure reason!");
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/diffusion/controller/file');
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/query/browse/base');
|
phutil_require_module('phabricator', 'applications/diffusion/query/browse/base');
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/view/browsetable');
|
phutil_require_module('phabricator', 'applications/diffusion/view/browsetable');
|
||||||
phutil_require_module('phabricator', 'view/form/error');
|
phutil_require_module('phabricator', 'view/form/error');
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?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 DiffusionBrowseFileController extends DiffusionController {
|
||||||
|
|
||||||
|
private $callsign;
|
||||||
|
private $path;
|
||||||
|
private $line;
|
||||||
|
private $commit;
|
||||||
|
private $view;
|
||||||
|
|
||||||
|
private $repository;
|
||||||
|
|
||||||
|
public function setRepository(DiffusionRepository $repository) {
|
||||||
|
$this->repository = $repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCommit($commit) {
|
||||||
|
$this->commit = $commit;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPath($path) {
|
||||||
|
$this->path = $path;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$file_query = DiffusionFileContentQuery::newFromRepository(
|
||||||
|
$this->repository,
|
||||||
|
$this->path,
|
||||||
|
$this->commit);
|
||||||
|
$file_content = $file_query->loadFileContent();
|
||||||
|
|
||||||
|
$corpus = phutil_render_tag(
|
||||||
|
'textarea',
|
||||||
|
array(
|
||||||
|
),
|
||||||
|
phutil_escape_html($file_content->getCorpus()));
|
||||||
|
|
||||||
|
// TODO: blame, color, line numbers, highlighting, etc etc
|
||||||
|
|
||||||
|
return $this->buildStandardPageResponse(
|
||||||
|
$corpus,
|
||||||
|
array(
|
||||||
|
'title' => 'Browse',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
15
src/applications/diffusion/controller/file/__init__.php
Normal file
15
src/applications/diffusion/controller/file/__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/diffusion/controller/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/diffusion/query/filecontent/base');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DiffusionBrowseFileController.php');
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
final class DiffusionFileContent {
|
||||||
|
|
||||||
|
private $corpus;
|
||||||
|
|
||||||
|
final public function setCorpus($corpus) {
|
||||||
|
$this->corpus = $corpus;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getCorpus() {
|
||||||
|
return $this->corpus;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
10
src/applications/diffusion/data/filecontent/__init__.php
Normal file
10
src/applications/diffusion/data/filecontent/__init__.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DiffusionFileContent.php');
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?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 DiffusionFileContentQuery {
|
||||||
|
|
||||||
|
private $repository;
|
||||||
|
private $path;
|
||||||
|
private $commit;
|
||||||
|
|
||||||
|
final private function __construct() {
|
||||||
|
// <private>
|
||||||
|
}
|
||||||
|
|
||||||
|
final public static function newFromRepository(
|
||||||
|
PhabricatorRepository $repository,
|
||||||
|
$path = '/',
|
||||||
|
$commit = null) {
|
||||||
|
|
||||||
|
switch ($repository->getVersionControlSystem()) {
|
||||||
|
case 'git':
|
||||||
|
$class = 'DiffusionGitFileContentQuery';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception("Unsupported VCS!");
|
||||||
|
}
|
||||||
|
|
||||||
|
PhutilSymbolLoader::loadClass($class);
|
||||||
|
$query = new $class();
|
||||||
|
|
||||||
|
$query->repository = $repository;
|
||||||
|
$query->path = $path;
|
||||||
|
$query->commit = $commit;
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getRepository() {
|
||||||
|
return $this->repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getPath() {
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getCommit() {
|
||||||
|
return $this->commit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final public function loadFileContent() {
|
||||||
|
return $this->executeQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected function executeQuery();
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'symbols');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DiffusionFileContentQuery.php');
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
final class DiffusionGitFileContentQuery extends DiffusionFileContentQuery {
|
||||||
|
|
||||||
|
protected function executeQuery() {
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
$path = $this->getPath();
|
||||||
|
$commit = nonempty($this->getCommit(), 'HEAD');
|
||||||
|
|
||||||
|
$local_path = $repository->getDetail('local-path');
|
||||||
|
$git = PhabricatorEnv::getEnvConfig('git.path');
|
||||||
|
|
||||||
|
list($corpus) = execx(
|
||||||
|
'(cd %s && %s cat-file blob %s:%s)',
|
||||||
|
$local_path,
|
||||||
|
$git,
|
||||||
|
$commit,
|
||||||
|
$path);
|
||||||
|
|
||||||
|
$file_content = new DiffusionFileContent();
|
||||||
|
$file_content->setCorpus($corpus);
|
||||||
|
|
||||||
|
return $file_content;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/diffusion/data/filecontent');
|
||||||
|
phutil_require_module('phabricator', 'applications/diffusion/query/filecontent/base');
|
||||||
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'future/exec');
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DiffusionGitFileContentQuery.php');
|
Loading…
Reference in a new issue