2012-05-09 19:01:31 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Upgrade arcanist itself.
|
|
|
|
*
|
|
|
|
* @group workflow
|
|
|
|
*/
|
|
|
|
final class ArcanistUpgradeWorkflow extends ArcanistBaseWorkflow {
|
|
|
|
|
Make Arcanist workflow names explicit
Summary:
Currently, adding a new workflow requires you to override ArcanistConfiguration, which is messy. Instead, just load everything that extends ArcanistBaseWorkflow.
Remove all the rules tying workflow names to class names through arcane incantations.
This has a very small performance cost in that we need to load every Workflow class every time now, but we don't hit __init__ and such anymore and it was pretty negligible on my machine (98ms vs 104ms or something).
Test Plan: Ran "arc help", "arc which", "arc diff", etc.
Reviewers: edward, vrana, btrahan
Reviewed By: edward
CC: aran, zeeg
Differential Revision: https://secure.phabricator.com/D3691
2012-10-17 17:35:03 +02:00
|
|
|
public function getWorkflowName() {
|
|
|
|
return 'upgrade';
|
|
|
|
}
|
|
|
|
|
2012-05-09 19:01:31 +02:00
|
|
|
public function getCommandSynopses() {
|
|
|
|
return phutil_console_format(<<<EOTEXT
|
|
|
|
**upgrade**
|
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandHelp() {
|
|
|
|
return phutil_console_format(<<<EOTEXT
|
|
|
|
Supports: cli
|
2012-05-22 01:45:03 +02:00
|
|
|
Upgrade arcanist and libphutil to the latest versions.
|
2012-05-09 19:01:31 +02:00
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getArguments() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function run() {
|
2012-05-22 01:45:03 +02:00
|
|
|
$roots = array();
|
|
|
|
$roots['libphutil'] = dirname(phutil_get_library_root('phutil'));
|
|
|
|
$roots['arcanist'] = dirname(phutil_get_library_root('arcanist'));
|
2012-05-09 19:01:31 +02:00
|
|
|
|
2012-05-22 01:45:03 +02:00
|
|
|
foreach ($roots as $lib => $root) {
|
|
|
|
echo "Upgrading {$lib}...\n";
|
2012-05-09 19:01:31 +02:00
|
|
|
|
2012-05-22 01:45:03 +02:00
|
|
|
if (!Filesystem::pathExists($root.'/.git')) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"{$lib} must be in its git working copy to be automatically ".
|
|
|
|
"upgraded. This copy of {$lib} (in '{$root}') is not in a git ".
|
|
|
|
"working copy.");
|
|
|
|
}
|
2012-05-09 19:01:31 +02:00
|
|
|
|
2012-05-22 01:45:03 +02:00
|
|
|
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
|
2012-05-09 19:01:31 +02:00
|
|
|
|
2012-05-22 01:45:03 +02:00
|
|
|
$repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
|
|
|
|
$working_copy);
|
2012-07-03 04:50:35 +02:00
|
|
|
|
2012-05-22 01:45:03 +02:00
|
|
|
$this->setRepositoryAPI($repository_api);
|
2012-05-09 19:01:31 +02:00
|
|
|
|
2012-05-22 01:45:03 +02:00
|
|
|
// Require no local changes.
|
|
|
|
$this->requireCleanWorkingCopy();
|
|
|
|
|
|
|
|
// Require the library be on master.
|
|
|
|
$branch_name = $repository_api->getBranchName();
|
|
|
|
if ($branch_name != 'master') {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"{$lib} must be on branch 'master' to be automatically upgraded. ".
|
|
|
|
"This copy of {$lib} (in '{$root}') is on branch '{$branch_name}'.");
|
|
|
|
}
|
2012-05-09 19:01:31 +02:00
|
|
|
|
2012-05-22 01:45:03 +02:00
|
|
|
chdir($root);
|
|
|
|
try {
|
|
|
|
phutil_passthru('git pull --rebase');
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
phutil_passthru('git rebase --abort');
|
|
|
|
throw $ex;
|
|
|
|
}
|
2012-05-09 19:01:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo phutil_console_wrap(
|
|
|
|
phutil_console_format(
|
|
|
|
"**Updated!** Your copy of arc is now up to date.\n"));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|