2015-10-24 17:13:22 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorConfigVersionsModule
|
|
|
|
extends PhabricatorConfigModule {
|
|
|
|
|
|
|
|
public function getModuleKey() {
|
|
|
|
return 'versions';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getModuleName() {
|
|
|
|
return pht('Versions');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderModuleStatus(AphrontRequest $request) {
|
|
|
|
$viewer = $request->getViewer();
|
|
|
|
|
2015-11-30 23:57:24 +01:00
|
|
|
$versions = $this->loadVersions($viewer);
|
2015-10-24 17:13:22 +02:00
|
|
|
|
|
|
|
$version_property_list = id(new PHUIPropertyListView());
|
2015-11-30 23:57:24 +01:00
|
|
|
foreach ($versions as $name => $version) {
|
|
|
|
$version_property_list->addProperty($name, $version);
|
2015-10-24 17:13:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Current Versions'))
|
|
|
|
->addPropertyList($version_property_list);
|
|
|
|
|
|
|
|
$phabricator_root = dirname(phutil_get_library_root('phabricator'));
|
|
|
|
$version_path = $phabricator_root.'/conf/local/VERSION';
|
|
|
|
if (Filesystem::pathExists($version_path)) {
|
|
|
|
$version_from_file = Filesystem::readFile($version_path);
|
|
|
|
$version_property_list->addProperty(
|
|
|
|
pht('Local Version'),
|
|
|
|
$version_from_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $object_box;
|
|
|
|
}
|
|
|
|
|
2015-11-30 23:57:24 +01:00
|
|
|
private function loadVersions(PhabricatorUser $viewer) {
|
2015-10-24 17:13:22 +02:00
|
|
|
$specs = array(
|
2015-11-30 23:57:24 +01:00
|
|
|
'phabricator',
|
|
|
|
'arcanist',
|
|
|
|
'phutil',
|
2015-10-24 17:13:22 +02:00
|
|
|
);
|
|
|
|
|
2015-11-30 23:57:24 +01:00
|
|
|
$all_libraries = PhutilBootloader::getInstance()->getAllLibraries();
|
|
|
|
$other_libraries = array_diff($all_libraries, ipull($specs, 'lib'));
|
|
|
|
$specs = $specs + $other_libraries;
|
|
|
|
|
|
|
|
|
2015-10-24 17:13:22 +02:00
|
|
|
$futures = array();
|
2015-11-30 23:57:24 +01:00
|
|
|
foreach ($specs as $lib) {
|
|
|
|
$root = dirname(phutil_get_library_root($lib));
|
|
|
|
$futures[$lib] =
|
|
|
|
id(new ExecFuture('git log --format=%s -n 1 --', '%H %ct'))
|
2015-10-24 17:13:22 +02:00
|
|
|
->setCWD($root);
|
|
|
|
}
|
|
|
|
|
|
|
|
$results = array();
|
|
|
|
foreach ($futures as $key => $future) {
|
|
|
|
list($err, $stdout) = $future->resolve();
|
|
|
|
if (!$err) {
|
2015-11-30 23:57:24 +01:00
|
|
|
list($hash, $epoch) = explode(' ', $stdout);
|
|
|
|
$version = pht('%s (%s)', $hash, phabricator_date($epoch, $viewer));
|
2015-10-24 17:13:22 +02:00
|
|
|
} else {
|
2015-11-30 23:57:24 +01:00
|
|
|
$version = pht('Unknown');
|
2015-10-24 17:13:22 +02:00
|
|
|
}
|
2015-11-30 23:57:24 +01:00
|
|
|
$results[$key] = $version;
|
2015-10-24 17:13:22 +02:00
|
|
|
}
|
|
|
|
|
2015-11-30 23:57:24 +01:00
|
|
|
return $results;
|
2015-10-24 17:13:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|