1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-11 15:21:03 +01:00

Versions Panel: Show extensions, dates

Summary: ref T9788

Test Plan: {F1008540}

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T9788

Differential Revision: https://secure.phabricator.com/D14610
This commit is contained in:
Aviv Eyal 2015-11-30 22:57:24 +00:00 committed by avivey
parent 065df01f65
commit 2fba7e66e7

View file

@ -14,13 +14,11 @@ final class PhabricatorConfigVersionsModule
public function renderModuleStatus(AphrontRequest $request) { public function renderModuleStatus(AphrontRequest $request) {
$viewer = $request->getViewer(); $viewer = $request->getViewer();
$versions = $this->loadVersions($viewer);
$versions = $this->loadVersions();
$version_property_list = id(new PHUIPropertyListView()); $version_property_list = id(new PHUIPropertyListView());
foreach ($versions as $version) { foreach ($versions as $name => $version) {
list($name, $hash) = $version; $version_property_list->addProperty($name, $version);
$version_property_list->addProperty($name, $hash);
} }
$object_box = id(new PHUIObjectBoxView()) $object_box = id(new PHUIObjectBoxView())
@ -39,26 +37,23 @@ final class PhabricatorConfigVersionsModule
return $object_box; return $object_box;
} }
private function loadVersions() { private function loadVersions(PhabricatorUser $viewer) {
$specs = array( $specs = array(
array( 'phabricator',
'name' => pht('Phabricator Version'), 'arcanist',
'root' => 'phabricator', 'phutil',
),
array(
'name' => pht('Arcanist Version'),
'root' => 'arcanist',
),
array(
'name' => pht('libphutil Version'),
'root' => 'phutil',
),
); );
$all_libraries = PhutilBootloader::getInstance()->getAllLibraries();
$other_libraries = array_diff($all_libraries, ipull($specs, 'lib'));
$specs = $specs + $other_libraries;
$futures = array(); $futures = array();
foreach ($specs as $key => $spec) { foreach ($specs as $lib) {
$root = dirname(phutil_get_library_root($spec['root'])); $root = dirname(phutil_get_library_root($lib));
$futures[$key] = id(new ExecFuture('git log --format=%%H -n 1 --')) $futures[$lib] =
id(new ExecFuture('git log --format=%s -n 1 --', '%H %ct'))
->setCWD($root); ->setCWD($root);
} }
@ -66,14 +61,15 @@ final class PhabricatorConfigVersionsModule
foreach ($futures as $key => $future) { foreach ($futures as $key => $future) {
list($err, $stdout) = $future->resolve(); list($err, $stdout) = $future->resolve();
if (!$err) { if (!$err) {
$name = trim($stdout); list($hash, $epoch) = explode(' ', $stdout);
$version = pht('%s (%s)', $hash, phabricator_date($epoch, $viewer));
} else { } else {
$name = pht('Unknown'); $version = pht('Unknown');
} }
$results[$key] = array($specs[$key]['name'], $name); $results[$key] = $version;
} }
return array_select_keys($results, array_keys($specs)); return $results;
} }
} }