mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 13:00:56 +01:00
Add a "properties" table to the Repository view in Diffusion
Summary: Notably, expose the clone URI / remote URI, after stripping credentials. Test Plan: Looked at a repository. Reviewers: btrahan, nh Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T91 Differential Revision: https://secure.phabricator.com/D1811
This commit is contained in:
parent
17d801a50e
commit
1c80a4eb58
3 changed files with 52 additions and 0 deletions
|
@ -26,6 +26,8 @@ class DiffusionRepositoryController extends DiffusionController {
|
|||
$crumbs = $this->buildCrumbs();
|
||||
$content[] = $crumbs;
|
||||
|
||||
$content[] = $this->buildPropertiesTable($drequest->getRepository());
|
||||
|
||||
$history_query = DiffusionHistoryQuery::newFromDiffusionRequest(
|
||||
$drequest);
|
||||
$history_query->setLimit(15);
|
||||
|
@ -110,4 +112,41 @@ class DiffusionRepositoryController extends DiffusionController {
|
|||
));
|
||||
}
|
||||
|
||||
private function buildPropertiesTable(PhabricatorRepository $repository) {
|
||||
|
||||
$properties = array();
|
||||
$properties['Name'] = $repository->getName();
|
||||
$properties['Callsign'] = $repository->getCallsign();
|
||||
$properties['Description'] = $repository->getDetail('description');
|
||||
switch ($repository->getVersionControlSystem()) {
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
||||
$properties['Clone URI'] = $repository->getPublicRemoteURI();
|
||||
break;
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||
$properties['Repository Root'] = $repository->getPublicRemoteURI();
|
||||
break;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
foreach ($properties as $key => $value) {
|
||||
$rows[] = array(
|
||||
phutil_escape_html($key),
|
||||
phutil_escape_html($value));
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
'header',
|
||||
'wide',
|
||||
));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader('Repository Properties');
|
||||
$panel->appendChild($table);
|
||||
|
||||
return $panel;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ phutil_require_module('phabricator', 'applications/diffusion/view/branchtable');
|
|||
phutil_require_module('phabricator', 'applications/diffusion/view/browsetable');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/view/historytable');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
|
|
|
@ -320,6 +320,17 @@ class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
|||
}
|
||||
}
|
||||
|
||||
public function getPublicRemoteURI() {
|
||||
$uri = new PhutilURI($this->getRemoteURI());
|
||||
|
||||
// Make sure we don't leak anything if this repo is using HTTP Basic Auth
|
||||
// with the credentials in the URI or something zany like that.
|
||||
$uri->setUser(null);
|
||||
$uri->setPass(null);
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
private function isSSHProtocol($protocol) {
|
||||
return ($protocol == 'ssh' || $protocol == 'svn+ssh');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue