2011-03-13 01:17:34 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DiffusionRepositoryController extends DiffusionController {
|
2011-03-13 01:17:34 +01:00
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$drequest = $this->diffusionRequest;
|
|
|
|
|
|
|
|
$content = array();
|
|
|
|
|
|
|
|
$crumbs = $this->buildCrumbs();
|
|
|
|
$content[] = $crumbs;
|
|
|
|
|
2012-03-08 21:46:19 +01:00
|
|
|
$content[] = $this->buildPropertiesTable($drequest->getRepository());
|
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
$history_query = DiffusionHistoryQuery::newFromDiffusionRequest(
|
|
|
|
$drequest);
|
|
|
|
$history_query->setLimit(15);
|
2012-03-24 01:11:15 +01:00
|
|
|
$history_query->needParents(true);
|
2011-03-13 01:17:34 +01:00
|
|
|
$history = $history_query->loadHistory();
|
2011-04-03 01:39:23 +02:00
|
|
|
|
Diffusion - move DiffusionBrowseQuery => Conduit
Summary: see title. Ref T2784.
Test Plan:
In diffusion, for each of SVN, Mercurial, and Git, I loaded up /diffusion/CALLSIGN/. I verified the README was displayed and things looked good. Next I clicked on "browse" on the top-most commit and verified things looked correct. Also clicked through to a file for a good measure and things looked good.
In owners, for each of SVN, Mercurial, and Git, I played around with the path typeahead / validator. It worked correctly!
Reviewers: epriestley
Reviewed By: epriestley
CC: chad, aran, Korvin
Maniphest Tasks: T2784
Differential Revision: https://secure.phabricator.com/D5883
2013-05-10 20:02:58 +02:00
|
|
|
$browse_results = DiffusionBrowseResultSet::newFromConduit(
|
|
|
|
$this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.browsequery',
|
|
|
|
array(
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
'renderReadme' => true,
|
|
|
|
)));
|
|
|
|
$browse_paths = $browse_results->getPaths();
|
2011-04-03 01:39:23 +02:00
|
|
|
|
|
|
|
$phids = array();
|
|
|
|
|
|
|
|
foreach ($history as $item) {
|
|
|
|
$data = $item->getCommitData();
|
|
|
|
if ($data) {
|
|
|
|
if ($data->getCommitDetail('authorPHID')) {
|
|
|
|
$phids[$data->getCommitDetail('authorPHID')] = true;
|
|
|
|
}
|
2012-05-23 17:34:36 +02:00
|
|
|
if ($data->getCommitDetail('committerPHID')) {
|
|
|
|
$phids[$data->getCommitDetail('committerPHID')] = true;
|
|
|
|
}
|
2011-04-03 01:39:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Diffusion - move DiffusionBrowseQuery => Conduit
Summary: see title. Ref T2784.
Test Plan:
In diffusion, for each of SVN, Mercurial, and Git, I loaded up /diffusion/CALLSIGN/. I verified the README was displayed and things looked good. Next I clicked on "browse" on the top-most commit and verified things looked correct. Also clicked through to a file for a good measure and things looked good.
In owners, for each of SVN, Mercurial, and Git, I played around with the path typeahead / validator. It worked correctly!
Reviewers: epriestley
Reviewed By: epriestley
CC: chad, aran, Korvin
Maniphest Tasks: T2784
Differential Revision: https://secure.phabricator.com/D5883
2013-05-10 20:02:58 +02:00
|
|
|
foreach ($browse_paths as $item) {
|
2011-04-03 01:39:23 +02:00
|
|
|
$data = $item->getLastCommitData();
|
|
|
|
if ($data) {
|
|
|
|
if ($data->getCommitDetail('authorPHID')) {
|
|
|
|
$phids[$data->getCommitDetail('authorPHID')] = true;
|
|
|
|
}
|
2012-05-23 17:34:36 +02:00
|
|
|
if ($data->getCommitDetail('committerPHID')) {
|
|
|
|
$phids[$data->getCommitDetail('committerPHID')] = true;
|
|
|
|
}
|
2011-04-03 01:39:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$phids = array_keys($phids);
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2011-04-03 01:39:23 +02:00
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
$history_table = new DiffusionHistoryTableView();
|
2012-12-21 00:04:20 +01:00
|
|
|
$history_table->setUser($this->getRequest()->getUser());
|
2011-03-13 01:17:34 +01:00
|
|
|
$history_table->setDiffusionRequest($drequest);
|
2011-04-03 01:39:23 +02:00
|
|
|
$history_table->setHandles($handles);
|
2011-03-13 01:17:34 +01:00
|
|
|
$history_table->setHistory($history);
|
2012-06-23 01:52:08 +02:00
|
|
|
$history_table->loadRevisions();
|
2012-03-24 01:11:15 +01:00
|
|
|
$history_table->setParents($history_query->getParents());
|
|
|
|
$history_table->setIsHead(true);
|
2011-03-13 01:17:34 +01:00
|
|
|
|
2011-03-13 07:51:40 +01:00
|
|
|
$callsign = $drequest->getRepository()->getCallsign();
|
2013-01-18 03:57:09 +01:00
|
|
|
$all = phutil_tag(
|
2011-03-13 07:51:40 +01:00
|
|
|
'a',
|
|
|
|
array(
|
2012-12-04 03:23:33 +01:00
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'history',
|
|
|
|
)),
|
2011-03-13 07:51:40 +01:00
|
|
|
),
|
|
|
|
'View Full Commit History');
|
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
$panel = new AphrontPanelView();
|
2013-02-13 23:50:15 +01:00
|
|
|
$panel->setHeader(hsprintf("Recent Commits · %s", $all));
|
2011-03-13 01:17:34 +01:00
|
|
|
$panel->appendChild($history_table);
|
2013-01-15 01:40:04 +01:00
|
|
|
$panel->setNoBackground();
|
2011-03-13 01:17:34 +01:00
|
|
|
|
|
|
|
$content[] = $panel;
|
|
|
|
|
|
|
|
|
|
|
|
$browse_table = new DiffusionBrowseTableView();
|
|
|
|
$browse_table->setDiffusionRequest($drequest);
|
2011-04-03 01:39:23 +02:00
|
|
|
$browse_table->setHandles($handles);
|
Diffusion - move DiffusionBrowseQuery => Conduit
Summary: see title. Ref T2784.
Test Plan:
In diffusion, for each of SVN, Mercurial, and Git, I loaded up /diffusion/CALLSIGN/. I verified the README was displayed and things looked good. Next I clicked on "browse" on the top-most commit and verified things looked correct. Also clicked through to a file for a good measure and things looked good.
In owners, for each of SVN, Mercurial, and Git, I played around with the path typeahead / validator. It worked correctly!
Reviewers: epriestley
Reviewed By: epriestley
CC: chad, aran, Korvin
Maniphest Tasks: T2784
Differential Revision: https://secure.phabricator.com/D5883
2013-05-10 20:02:58 +02:00
|
|
|
$browse_table->setPaths($browse_paths);
|
2012-08-02 21:22:50 +02:00
|
|
|
$browse_table->setUser($this->getRequest()->getUser());
|
2011-03-13 01:17:34 +01:00
|
|
|
|
|
|
|
$browse_panel = new AphrontPanelView();
|
2013-02-21 21:58:40 +01:00
|
|
|
$browse_panel->setHeader(phutil_tag(
|
|
|
|
'a',
|
|
|
|
array('href' => $drequest->generateURI(array('action' => 'browse'))),
|
|
|
|
'Browse Repository'));
|
2011-03-13 01:17:34 +01:00
|
|
|
$browse_panel->appendChild($browse_table);
|
2013-01-15 01:40:04 +01:00
|
|
|
$browse_panel->setNoBackground();
|
2011-03-13 01:17:34 +01:00
|
|
|
|
|
|
|
$content[] = $browse_panel;
|
|
|
|
|
2012-04-18 17:02:08 +02:00
|
|
|
$content[] = $this->buildTagListTable($drequest);
|
|
|
|
|
2012-05-10 09:28:19 +02:00
|
|
|
$content[] = $this->buildBranchListTable($drequest);
|
2011-03-13 01:17:34 +01:00
|
|
|
|
Diffusion - move DiffusionBrowseQuery => Conduit
Summary: see title. Ref T2784.
Test Plan:
In diffusion, for each of SVN, Mercurial, and Git, I loaded up /diffusion/CALLSIGN/. I verified the README was displayed and things looked good. Next I clicked on "browse" on the top-most commit and verified things looked correct. Also clicked through to a file for a good measure and things looked good.
In owners, for each of SVN, Mercurial, and Git, I played around with the path typeahead / validator. It worked correctly!
Reviewers: epriestley
Reviewed By: epriestley
CC: chad, aran, Korvin
Maniphest Tasks: T2784
Differential Revision: https://secure.phabricator.com/D5883
2013-05-10 20:02:58 +02:00
|
|
|
$readme = $browse_results->getReadmeContent();
|
2012-04-30 16:47:41 +02:00
|
|
|
if ($readme) {
|
|
|
|
$panel = new AphrontPanelView();
|
|
|
|
$panel->setHeader('README');
|
|
|
|
$panel->appendChild($readme);
|
|
|
|
$content[] = $panel;
|
|
|
|
}
|
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
return $this->buildStandardPageResponse(
|
|
|
|
$content,
|
|
|
|
array(
|
2012-01-20 22:27:32 +01:00
|
|
|
'title' => $drequest->getRepository()->getName(),
|
2011-03-13 01:17:34 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-03-08 21:46:19 +01:00
|
|
|
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) {
|
2013-02-13 23:50:15 +01:00
|
|
|
$rows[] = array($key, $value);
|
2012-03-08 21:46:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$table = new AphrontTableView($rows);
|
|
|
|
$table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'header',
|
|
|
|
'wide',
|
|
|
|
));
|
|
|
|
|
|
|
|
$panel = new AphrontPanelView();
|
|
|
|
$panel->setHeader('Repository Properties');
|
|
|
|
$panel->appendChild($table);
|
2013-01-15 01:40:04 +01:00
|
|
|
$panel->setNoBackground();
|
2012-03-08 21:46:19 +01:00
|
|
|
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
2012-05-10 09:28:19 +02:00
|
|
|
private function buildBranchListTable(DiffusionRequest $drequest) {
|
|
|
|
if ($drequest->getBranch() !== null) {
|
|
|
|
$limit = 15;
|
|
|
|
|
2013-05-01 23:56:36 +02:00
|
|
|
$branches = DiffusionBranchInformation::newFromConduit(
|
|
|
|
$this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.branchquery',
|
|
|
|
array(
|
|
|
|
'limit' => $limit
|
|
|
|
)));
|
2012-05-10 09:28:19 +02:00
|
|
|
if (!$branches) {
|
2013-05-01 23:56:36 +02:00
|
|
|
return null;
|
2012-05-10 09:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$more_branches = (count($branches) > $limit);
|
|
|
|
$branches = array_slice($branches, 0, $limit);
|
|
|
|
|
|
|
|
$commits = id(new PhabricatorAuditCommitQuery())
|
|
|
|
->withIdentifiers(
|
|
|
|
$drequest->getRepository()->getID(),
|
|
|
|
mpull($branches, 'getHeadCommitIdentifier'))
|
|
|
|
->needCommitData(true)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$table = new DiffusionBranchTableView();
|
|
|
|
$table->setDiffusionRequest($drequest);
|
|
|
|
$table->setBranches($branches);
|
|
|
|
$table->setCommits($commits);
|
|
|
|
$table->setUser($this->getRequest()->getUser());
|
|
|
|
|
|
|
|
$panel = new AphrontPanelView();
|
|
|
|
$panel->setHeader('Branches');
|
2013-01-15 01:40:04 +01:00
|
|
|
$panel->setNoBackground();
|
2012-05-10 09:28:19 +02:00
|
|
|
|
|
|
|
if ($more_branches) {
|
2012-05-10 23:18:49 +02:00
|
|
|
$panel->setCaption('Showing ' . $limit . ' branches.');
|
2012-05-10 09:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$panel->addButton(
|
2013-01-18 03:57:09 +01:00
|
|
|
phutil_tag(
|
2012-05-10 23:18:49 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $drequest->generateURI(
|
2012-05-10 09:28:19 +02:00
|
|
|
array(
|
2012-05-10 23:18:49 +02:00
|
|
|
'action' => 'branches',
|
|
|
|
)),
|
|
|
|
'class' => 'grey button',
|
|
|
|
),
|
|
|
|
"Show All Branches \xC2\xBB"));
|
2012-05-10 09:28:19 +02:00
|
|
|
|
|
|
|
$panel->appendChild($table);
|
|
|
|
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-04-18 17:02:08 +02:00
|
|
|
private function buildTagListTable(DiffusionRequest $drequest) {
|
2012-05-10 09:28:19 +02:00
|
|
|
$tag_limit = 15;
|
2012-04-19 18:39:19 +02:00
|
|
|
|
2012-04-18 17:02:08 +02:00
|
|
|
$query = DiffusionTagListQuery::newFromDiffusionRequest($drequest);
|
2012-04-19 18:39:19 +02:00
|
|
|
$query->setLimit($tag_limit + 1);
|
2012-04-18 17:02:08 +02:00
|
|
|
$tags = $query->loadTags();
|
|
|
|
|
|
|
|
if (!$tags) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-04-19 18:39:19 +02:00
|
|
|
$more_tags = (count($tags) > $tag_limit);
|
|
|
|
$tags = array_slice($tags, 0, $tag_limit);
|
|
|
|
|
2012-04-18 17:02:08 +02:00
|
|
|
$commits = id(new PhabricatorAuditCommitQuery())
|
|
|
|
->withIdentifiers(
|
|
|
|
$drequest->getRepository()->getID(),
|
|
|
|
mpull($tags, 'getCommitIdentifier'))
|
|
|
|
->needCommitData(true)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$view = new DiffusionTagListView();
|
|
|
|
$view->setDiffusionRequest($drequest);
|
|
|
|
$view->setTags($tags);
|
|
|
|
$view->setUser($this->getRequest()->getUser());
|
|
|
|
$view->setCommits($commits);
|
|
|
|
|
|
|
|
$phids = $view->getRequiredHandlePHIDs();
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2012-04-18 17:02:08 +02:00
|
|
|
$view->setHandles($handles);
|
|
|
|
|
|
|
|
$panel = new AphrontPanelView();
|
|
|
|
$panel->setHeader('Tags');
|
2012-04-19 18:39:19 +02:00
|
|
|
|
|
|
|
if ($more_tags) {
|
|
|
|
$panel->setCaption('Showing the '.$tag_limit.' most recent tags.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$panel->addButton(
|
2013-01-18 03:57:09 +01:00
|
|
|
phutil_tag(
|
2012-04-19 18:39:19 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'tags',
|
|
|
|
)),
|
|
|
|
'class' => 'grey button',
|
|
|
|
),
|
|
|
|
"Show All Tags \xC2\xBB"));
|
2012-04-18 17:02:08 +02:00
|
|
|
$panel->appendChild($view);
|
|
|
|
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
}
|