2014-03-26 15:42:30 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionPushEventViewController
|
2018-01-23 05:09:52 +01:00
|
|
|
extends DiffusionLogController {
|
2014-03-26 15:42:30 +01:00
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $this->getViewer();
|
2014-03-26 15:42:30 +01:00
|
|
|
|
|
|
|
$event = id(new PhabricatorRepositoryPushEventQuery())
|
|
|
|
->setViewer($viewer)
|
2015-01-09 22:29:08 +01:00
|
|
|
->withIDs(array($request->getURIData('id')))
|
2014-03-26 15:42:30 +01:00
|
|
|
->needLogs(true)
|
|
|
|
->executeOne();
|
|
|
|
if (!$event) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$repository = $event->getRepository();
|
|
|
|
$title = pht('Push %d', $event->getID());
|
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addTextCrumb(
|
|
|
|
$repository->getName(),
|
2016-01-02 20:28:31 +01:00
|
|
|
$repository->getURI());
|
|
|
|
|
2014-03-26 15:42:30 +01:00
|
|
|
$crumbs->addTextCrumb(
|
|
|
|
pht('Push Logs'),
|
|
|
|
$this->getApplicationURI(
|
|
|
|
'pushlog/?repositories='.$repository->getMonogram()));
|
|
|
|
$crumbs->addTextCrumb($title);
|
|
|
|
|
|
|
|
$event_properties = $this->buildPropertyList($event);
|
|
|
|
|
|
|
|
$detail_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText($title)
|
|
|
|
->addPropertyList($event_properties);
|
|
|
|
|
|
|
|
$commits = $this->loadCommits($event);
|
|
|
|
$commits_table = $this->renderCommitsTable($event, $commits);
|
|
|
|
|
|
|
|
$commits_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Pushed Commits'))
|
2015-05-20 08:14:22 +02:00
|
|
|
->setTable($commits_table);
|
2014-03-26 15:42:30 +01:00
|
|
|
|
2014-05-13 23:00:24 +02:00
|
|
|
$logs = $event->getLogs();
|
|
|
|
|
|
|
|
$updates_table = id(new DiffusionPushLogListView())
|
|
|
|
->setUser($viewer)
|
2016-04-20 05:25:21 +02:00
|
|
|
->setLogs($logs);
|
2014-03-26 15:42:30 +01:00
|
|
|
|
|
|
|
$update_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('All Pushed Updates'))
|
2015-05-20 08:14:22 +02:00
|
|
|
->setTable($updates_table);
|
2014-03-26 15:42:30 +01:00
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
return $this->newPage()
|
|
|
|
->setTitle($title)
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->appendChild(
|
|
|
|
array(
|
|
|
|
$detail_box,
|
|
|
|
$commits_box,
|
|
|
|
$update_box,
|
|
|
|
));
|
2014-03-26 15:42:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyList(PhabricatorRepositoryPushEvent $event) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
$view = new PHUIPropertyListView();
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Pushed At'),
|
|
|
|
phabricator_datetime($event->getEpoch(), $viewer));
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Pushed By'),
|
2015-03-30 16:55:33 +02:00
|
|
|
$viewer->renderHandle($event->getPusherPHID()));
|
2014-03-26 15:42:30 +01:00
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Pushed Via'),
|
|
|
|
$event->getRemoteProtocol());
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function loadCommits(PhabricatorRepositoryPushEvent $event) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$identifiers = array();
|
|
|
|
foreach ($event->getLogs() as $log) {
|
|
|
|
if ($log->getRefType() == PhabricatorRepositoryPushLog::REFTYPE_COMMIT) {
|
|
|
|
$identifiers[] = $log->getRefNew();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$identifiers) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Commits may not have been parsed/discovered yet. We need to return
|
|
|
|
// the identifiers no matter what. If possible, we'll also return the
|
|
|
|
// corresponding commits.
|
|
|
|
|
|
|
|
$commits = id(new DiffusionCommitQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withRepository($event->getRepository())
|
|
|
|
->withIdentifiers($identifiers)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$commits = mpull($commits, null, 'getCommitIdentifier');
|
|
|
|
|
|
|
|
$results = array();
|
|
|
|
foreach ($identifiers as $identifier) {
|
|
|
|
$results[$identifier] = idx($commits, $identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderCommitsTable(
|
|
|
|
PhabricatorRepositoryPushEvent $event,
|
|
|
|
array $commits) {
|
|
|
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
$repository = $event->getRepository();
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($commits as $identifier => $commit) {
|
|
|
|
if ($commit) {
|
|
|
|
$partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE |
|
|
|
|
PhabricatorRepositoryCommit::IMPORTED_CHANGE;
|
|
|
|
if ($commit->isPartiallyImported($partial_import)) {
|
|
|
|
$summary = AphrontTableView::renderSingleDisplayLine(
|
|
|
|
$commit->getSummary());
|
|
|
|
} else {
|
|
|
|
$summary = phutil_tag('em', array(), pht('Importing...'));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$summary = phutil_tag('em', array(), pht('Discovering...'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$commit_name = $repository->formatCommitName($identifier);
|
|
|
|
if ($commit) {
|
|
|
|
$commit_name = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/'.$commit_name,
|
|
|
|
),
|
|
|
|
$commit_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
$rows[] = array(
|
|
|
|
$commit_name,
|
|
|
|
$summary,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setNoDataString(pht("This push didn't push any new commits."))
|
|
|
|
->setHeaders(
|
|
|
|
array(
|
|
|
|
pht('Commit'),
|
|
|
|
pht('Summary'),
|
|
|
|
))
|
|
|
|
->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'n',
|
|
|
|
'wide',
|
|
|
|
));
|
|
|
|
|
|
|
|
return $table;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|