Page MenuHomePhorge

ArcanistVersionWorkflow.php
No OneTemporary

ArcanistVersionWorkflow.php

<?php
/**
* Display the current version of Arcanist.
*/
final class ArcanistVersionWorkflow extends ArcanistBaseWorkflow {
public function getWorkflowName() {
return 'version';
}
public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**version** [__options__]
EOTEXT
);
}
public function getCommandHelp() {
return phutil_console_format(pht(<<<EOTEXT
Supports: cli
Shows the current version of arcanist.
EOTEXT
));
}
public function run() {
$console = PhutilConsole::getConsole();
if (!Filesystem::binaryExists('git')) {
throw new ArcanistUsageException(
'Cannot display current version without having `git` installed.');
}
$roots = array(
'arcanist' => dirname(phutil_get_library_root('arcanist')),
'libphutil' => dirname(phutil_get_library_root('phutil')),
);
foreach ($roots as $lib => $root) {
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
$configuration_manager = clone $this->getConfigurationManager();
$configuration_manager->setWorkingCopyIdentity($working_copy);
$repository = ArcanistRepositoryAPI::newAPIFromConfigurationManager(
$configuration_manager);
if (!Filesystem::pathExists($repository->getMetadataPath())) {
throw new ArcanistUsageException("{$lib} is not a git working copy.");
}
list($stdout) = $repository->execxLocal('log -1 --format=%s', '%H %ct');
list($commit, $timestamp) = explode(' ', $stdout);
$console->writeOut("%s %s (%s)\n",
$lib,
$commit,
date('j M Y', (int)$timestamp));
}
}
}

File Metadata

Mime Type
text/x-php
Expires
Sun, Jan 19, 12:47 (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1116402
Default Alt Text
ArcanistVersionWorkflow.php (1 KB)

Event Timeline