Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13993552
D8616.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
17 KB
Referenced Files
None
Subscribers
None
D8616.id.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -520,6 +520,8 @@
'DiffusionPathQuery' => 'applications/diffusion/query/DiffusionPathQuery.php',
'DiffusionPathQueryTestCase' => 'applications/diffusion/query/pathid/__tests__/DiffusionPathQueryTestCase.php',
'DiffusionPathValidateController' => 'applications/diffusion/controller/DiffusionPathValidateController.php',
+ 'DiffusionPushEventViewController' => 'applications/diffusion/controller/DiffusionPushEventViewController.php',
+ 'DiffusionPushLogController' => 'applications/diffusion/controller/DiffusionPushLogController.php',
'DiffusionPushLogListController' => 'applications/diffusion/controller/DiffusionPushLogListController.php',
'DiffusionQuery' => 'applications/diffusion/query/DiffusionQuery.php',
'DiffusionRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionRawDiffQuery.php',
@@ -3070,9 +3072,11 @@
'DiffusionPathCompleteController' => 'DiffusionController',
'DiffusionPathQueryTestCase' => 'PhabricatorTestCase',
'DiffusionPathValidateController' => 'DiffusionController',
+ 'DiffusionPushEventViewController' => 'DiffusionPushLogController',
+ 'DiffusionPushLogController' => 'DiffusionController',
'DiffusionPushLogListController' =>
array(
- 0 => 'DiffusionController',
+ 0 => 'DiffusionPushLogController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'DiffusionQuery' => 'PhabricatorQuery',
diff --git a/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php b/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
--- a/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
+++ b/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
@@ -47,9 +47,10 @@
'new/' => 'DiffusionRepositoryNewController',
'(?P<edit>create)/' => 'DiffusionRepositoryCreateController',
'(?P<edit>import)/' => 'DiffusionRepositoryCreateController',
- 'pushlog/(?:query/(?P<queryKey>[^/]+)/)?'
- => 'DiffusionPushLogListController',
-
+ 'pushlog/' => array(
+ '(?:query/(?P<queryKey>[^/]+)/)?' => 'DiffusionPushLogListController',
+ 'view/(?P<id>\d+)/' => 'DiffusionPushEventViewController',
+ ),
'(?P<callsign>[A-Z]+)/' => array(
'' => 'DiffusionRepositoryController',
diff --git a/src/applications/diffusion/controller/DiffusionPushEventViewController.php b/src/applications/diffusion/controller/DiffusionPushEventViewController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/controller/DiffusionPushEventViewController.php
@@ -0,0 +1,184 @@
+<?php
+
+final class DiffusionPushEventViewController
+ extends DiffusionPushLogController {
+
+ private $id;
+
+ public function shouldAllowPublic() {
+ return true;
+ }
+
+ public function willProcessRequest(array $data) {
+ $this->id = idx($data, 'id');
+ }
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $event = id(new PhabricatorRepositoryPushEventQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($this->id))
+ ->needLogs(true)
+ ->executeOne();
+ if (!$event) {
+ return new Aphront404Response();
+ }
+
+ $repository = $event->getRepository();
+ $title = pht('Push %d', $event->getID());
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addTextCrumb(
+ $repository->getName(),
+ $this->getApplicationURI($repository->getCallsign().'/'));
+ $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'))
+ ->appendChild($commits_table);
+
+ $updates_table = $this->renderPushLogTable($event->getLogs());
+
+ $update_box = id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('All Pushed Updates'))
+ ->appendChild($updates_table);
+
+ return $this->buildApplicationPage(
+ array(
+ $crumbs,
+ $detail_box,
+ $commits_box,
+ $update_box,
+ ),
+ array(
+ 'title' => $title,
+ 'device' => true,
+ ));
+ }
+
+ private function buildPropertyList(PhabricatorRepositoryPushEvent $event) {
+ $viewer = $this->getRequest()->getUser();
+
+ $this->loadHandles(array($event->getPusherPHID()));
+
+ $view = new PHUIPropertyListView();
+
+ $view->addProperty(
+ pht('Pushed At'),
+ phabricator_datetime($event->getEpoch(), $viewer));
+
+ $view->addProperty(
+ pht('Pushed By'),
+ $this->getHandle($event->getPusherPHID())->renderLink());
+
+ $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;
+ }
+
+}
diff --git a/src/applications/diffusion/controller/DiffusionPushLogListController.php b/src/applications/diffusion/controller/DiffusionPushLogController.php
copy from src/applications/diffusion/controller/DiffusionPushLogListController.php
copy to src/applications/diffusion/controller/DiffusionPushLogController.php
--- a/src/applications/diffusion/controller/DiffusionPushLogListController.php
+++ b/src/applications/diffusion/controller/DiffusionPushLogController.php
@@ -1,31 +1,8 @@
<?php
-final class DiffusionPushLogListController extends DiffusionController
- implements PhabricatorApplicationSearchResultsControllerInterface {
+abstract class DiffusionPushLogController extends DiffusionController {
- private $queryKey;
-
- public function shouldAllowPublic() {
- return true;
- }
-
- public function willProcessRequest(array $data) {
- $this->queryKey = idx($data, 'queryKey');
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $controller = id(new PhabricatorApplicationSearchController($request))
- ->setQueryKey($this->queryKey)
- ->setSearchEngine(new PhabricatorRepositoryPushLogSearchEngine())
- ->setNavigation($this->buildSideNavView());
-
- return $this->delegateToController($controller);
- }
-
- public function renderResultsList(
- array $logs,
- PhabricatorSavedQuery $query) {
+ public function renderPushLogTable(array $logs) {
$viewer = $this->getRequest()->getUser();
$this->loadHandles(mpull($logs, 'getPusherPHID'));
@@ -58,9 +35,16 @@
}
}
+ $event_id = $log->getPushEvent()->getID();
+
$callsign = $log->getRepository()->getCallsign();
$rows[] = array(
- $log->getPushEvent()->getID(),
+ phutil_tag(
+ 'a',
+ array(
+ 'href' => $this->getApplicationURI('pushlog/view/'.$event_id.'/'),
+ ),
+ $event_id),
phutil_tag(
'a',
array(
@@ -122,26 +106,7 @@
'date',
));
- $box = id(new PHUIBoxView())
- ->addMargin(PHUI::MARGIN_LARGE)
- ->appendChild($table);
-
- return $box;
- }
-
- public function buildSideNavView($for_app = false) {
- $viewer = $this->getRequest()->getUser();
-
- $nav = new AphrontSideNavFilterView();
- $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
-
- id(new PhabricatorRepositoryPushLogSearchEngine())
- ->setViewer($viewer)
- ->addNavigationItems($nav->getMenu());
-
- $nav->selectFilter(null);
-
- return $nav;
+ return $table;
}
}
diff --git a/src/applications/diffusion/controller/DiffusionPushLogListController.php b/src/applications/diffusion/controller/DiffusionPushLogListController.php
--- a/src/applications/diffusion/controller/DiffusionPushLogListController.php
+++ b/src/applications/diffusion/controller/DiffusionPushLogListController.php
@@ -1,6 +1,6 @@
<?php
-final class DiffusionPushLogListController extends DiffusionController
+final class DiffusionPushLogListController extends DiffusionPushLogController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
@@ -26,101 +26,8 @@
public function renderResultsList(
array $logs,
PhabricatorSavedQuery $query) {
- $viewer = $this->getRequest()->getUser();
- $this->loadHandles(mpull($logs, 'getPusherPHID'));
-
- // Figure out which repositories are editable. We only let you see remote
- // IPs if you have edit capability on a repository.
- $editable_repos = array();
- if ($logs) {
- $editable_repos = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withPHIDs(mpull($logs, 'getRepositoryPHID'))
- ->execute();
- $editable_repos = mpull($editable_repos, null, 'getPHID');
- }
-
- $rows = array();
- foreach ($logs as $log) {
-
- // Reveal this if it's valid and the user can edit the repository.
- $remote_addr = '-';
- if (isset($editable_repos[$log->getRepositoryPHID()])) {
- $remote_long = $log->getPushEvent()->getRemoteAddress();
- if ($remote_long) {
- $remote_addr = long2ip($remote_long);
- }
- }
-
- $callsign = $log->getRepository()->getCallsign();
- $rows[] = array(
- $log->getPushEvent()->getID(),
- phutil_tag(
- 'a',
- array(
- 'href' => $this->getApplicationURI($callsign.'/'),
- ),
- $callsign),
- $this->getHandle($log->getPusherPHID())->renderLink(),
- $remote_addr,
- $log->getPushEvent()->getRemoteProtocol(),
- $log->getRefType(),
- $log->getRefName(),
- phutil_tag(
- 'a',
- array(
- 'href' => '/r'.$callsign.$log->getRefOld(),
- ),
- $log->getRefOldShort()),
- phutil_tag(
- 'a',
- array(
- 'href' => '/r'.$callsign.$log->getRefNew(),
- ),
- $log->getRefNewShort()),
-
- // TODO: Make these human-readable.
- $log->getChangeFlags(),
- $log->getPushEvent()->getRejectCode(),
- phabricator_datetime($log->getEpoch(), $viewer),
- );
- }
-
- $table = id(new AphrontTableView($rows))
- ->setHeaders(
- array(
- pht('Push'),
- pht('Repository'),
- pht('Pusher'),
- pht('From'),
- pht('Via'),
- pht('Type'),
- pht('Name'),
- pht('Old'),
- pht('New'),
- pht('Flags'),
- pht('Code'),
- pht('Date'),
- ))
- ->setColumnClasses(
- array(
- '',
- '',
- '',
- '',
- '',
- '',
- 'wide',
- 'n',
- 'n',
- 'date',
- ));
+ $table = $this->renderPushLogTable($logs);
$box = id(new PHUIBoxView())
->addMargin(PHUI::MARGIN_LARGE)
diff --git a/src/applications/repository/query/PhabricatorRepositoryPushEventQuery.php b/src/applications/repository/query/PhabricatorRepositoryPushEventQuery.php
--- a/src/applications/repository/query/PhabricatorRepositoryPushEventQuery.php
+++ b/src/applications/repository/query/PhabricatorRepositoryPushEventQuery.php
@@ -7,6 +7,7 @@
private $phids;
private $repositoryPHIDs;
private $pusherPHIDs;
+ private $needLogs;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -28,6 +29,11 @@
return $this;
}
+ public function needLogs($need_logs) {
+ $this->needLogs = $need_logs;
+ return $this;
+ }
+
protected function loadPage() {
$table = new PhabricatorRepositoryPushEvent();
$conn_r = $table->establishConnection('r');
@@ -63,6 +69,24 @@
return $events;
}
+ public function didFilterPage(array $events) {
+ $phids = mpull($events, 'getPHID');
+
+ if ($this->needLogs) {
+ $logs = id(new PhabricatorRepositoryPushLogQuery())
+ ->setParentQuery($this)
+ ->setViewer($this->getViewer())
+ ->withPushEventPHIDs($phids)
+ ->execute();
+ $logs = mgroup($logs, 'getPushEventPHID');
+ foreach ($events as $key => $event) {
+ $event_logs = idx($logs, $event->getPHID(), array());
+ $event->attachLogs($event_logs);
+ }
+ }
+
+ return $events;
+ }
private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
diff --git a/src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php b/src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
--- a/src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
+++ b/src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
@@ -9,6 +9,7 @@
private $pusherPHIDs;
private $refTypes;
private $newRefs;
+ private $pushEventPHIDs;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -40,6 +41,11 @@
return $this;
}
+ public function withPushEventPHIDs(array $phids) {
+ $this->pushEventPHIDs = $phids;
+ return $this;
+ }
+
protected function loadPage() {
$table = new PhabricatorRepositoryPushLog();
$conn_r = $table->establishConnection('r');
@@ -57,7 +63,8 @@
public function willFilterPage(array $logs) {
$event_phids = mpull($logs, 'getPushEventPHID');
- $events = id(new PhabricatorRepositoryPushEventQuery())
+ $events = id(new PhabricatorObjectQuery())
+ ->setParentQuery($this)
->setViewer($this->getViewer())
->withPHIDs($event_phids)
->execute();
@@ -107,6 +114,13 @@
$this->pusherPHIDs);
}
+ if ($this->pushEventPHIDs) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'pushEventPHID in (%Ls)',
+ $this->pushEventPHIDs);
+ }
+
if ($this->refTypes) {
$where[] = qsprintf(
$conn_r,
diff --git a/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php b/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php
--- a/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php
@@ -17,6 +17,7 @@
protected $rejectDetails;
private $repository = self::ATTACHABLE;
+ private $logs = self::ATTACHABLE;
public static function initializeNewEvent(PhabricatorUser $viewer) {
return id(new PhabricatorRepositoryPushEvent())
@@ -44,6 +45,15 @@
return $this->assertAttached($this->repository);
}
+ public function attachLogs(array $logs) {
+ $this->logs = $logs;
+ return $this;
+ }
+
+ public function getLogs() {
+ return $this->assertAttached($this->logs);
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 23, 11:39 PM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6740192
Default Alt Text
D8616.id.diff (17 KB)
Attached To
Mode
D8616: Provide an "event" page for push logs, which shows details on all events in a given push
Attached
Detach File
Event Timeline
Log In to Comment