mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-23 22:10:54 +01:00
2ae0cb797d
Summary: This method is used in three cases: # For unit tests, to set the range to 'HEAD^' or '.^' in an agnostic way. # For "amend", to set the range to the commit to be amended (also 'HEAD^' or '.^'). # For "patch" and "upgrade" so we don't fail just because there's an invalid "base" rule somewhere in the config when doing clean-working-copy tests. For cases (1) and (2), introduce an "arc:this" rule to mean "the current commit". For case (3), remove the call; it is no longer necessary to check the commit range in order to do tests for the working copy state after D4095. Test Plan: Ran unit tests, "arc upgrade", "arc patch", "arc amend". Reviewers: vrana Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D4096
82 lines
2 KiB
PHP
82 lines
2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Upgrade arcanist itself.
|
|
*
|
|
* @group workflow
|
|
*/
|
|
final class ArcanistUpgradeWorkflow extends ArcanistBaseWorkflow {
|
|
|
|
public function getWorkflowName() {
|
|
return 'upgrade';
|
|
}
|
|
|
|
public function getCommandSynopses() {
|
|
return phutil_console_format(<<<EOTEXT
|
|
**upgrade**
|
|
EOTEXT
|
|
);
|
|
}
|
|
|
|
public function getCommandHelp() {
|
|
return phutil_console_format(<<<EOTEXT
|
|
Supports: cli
|
|
Upgrade arcanist and libphutil to the latest versions.
|
|
EOTEXT
|
|
);
|
|
}
|
|
|
|
public function getArguments() {
|
|
return array();
|
|
}
|
|
|
|
public function run() {
|
|
$roots = array();
|
|
$roots['libphutil'] = dirname(phutil_get_library_root('phutil'));
|
|
$roots['arcanist'] = dirname(phutil_get_library_root('arcanist'));
|
|
|
|
foreach ($roots as $lib => $root) {
|
|
echo "Upgrading {$lib}...\n";
|
|
|
|
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.");
|
|
}
|
|
|
|
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
|
|
|
|
$repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
|
|
$working_copy);
|
|
|
|
$this->setRepositoryAPI($repository_api);
|
|
|
|
// 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}'.");
|
|
}
|
|
|
|
chdir($root);
|
|
try {
|
|
phutil_passthru('git pull --rebase');
|
|
} catch (Exception $ex) {
|
|
phutil_passthru('git rebase --abort');
|
|
throw $ex;
|
|
}
|
|
}
|
|
|
|
echo phutil_console_wrap(
|
|
phutil_console_format(
|
|
"**Updated!** Your copy of arc is now up to date.\n"));
|
|
|
|
return 0;
|
|
}
|
|
|
|
}
|