1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-23 14:00:55 +01:00

Minor tidying of ArcanistUpgradeWorkflow

Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11554
This commit is contained in:
Joshua Spence 2015-02-01 11:00:36 +11:00
parent c76c5d893e
commit fcd882815a

View file

@ -24,43 +24,48 @@ EOTEXT
); );
} }
public function getArguments() {
return array();
}
public function run() { public function run() {
$roots = array(); $roots = array(
$roots['libphutil'] = dirname(phutil_get_library_root('phutil')); 'libphutil' => dirname(phutil_get_library_root('phutil')),
$roots['arcanist'] = dirname(phutil_get_library_root('arcanist')); 'arcanist' => dirname(phutil_get_library_root('arcanist')),
);
foreach ($roots as $lib => $root) { foreach ($roots as $lib => $root) {
echo "Upgrading {$lib}...\n"; echo pht('Upgrading %s...', $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); $working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
$configuration_manager = clone $this->getConfigurationManager(); $configuration_manager = clone $this->getConfigurationManager();
$configuration_manager->setWorkingCopyIdentity($working_copy); $configuration_manager->setWorkingCopyIdentity($working_copy);
$repository_api = ArcanistRepositoryAPI::newAPIFromConfigurationManager( $repository = ArcanistRepositoryAPI::newAPIFromConfigurationManager(
$configuration_manager); $configuration_manager);
$this->setRepositoryAPI($repository_api); if (!Filesystem::pathExists($repository->getMetadataPath())) {
throw new ArcanistUsageException(
pht(
"%s must be in its git working copy to be automatically upgraded. ".
"This copy of %s (in '%s') is not in a git working copy.",
$lib,
$lib,
$root));
}
$this->setRepositoryAPI($repository);
// Require no local changes. // Require no local changes.
$this->requireCleanWorkingCopy(); $this->requireCleanWorkingCopy();
// Require the library be on master. // Require the library be on master.
$branch_name = $repository_api->getBranchName(); $branch_name = $repository->getBranchName();
if ($branch_name != 'master') { if ($branch_name != 'master') {
throw new ArcanistUsageException( throw new ArcanistUsageException(
"{$lib} must be on branch 'master' to be automatically upgraded. ". pht(
"This copy of {$lib} (in '{$root}') is on branch '{$branch_name}'."); "%s must be on branch '%s' to be automatically upgraded. ".
"This copy of %s (in '%s') is on branch '%s'.",
$lib,
'master',
$lib,
$root,
$branch_name));
} }
chdir($root); chdir($root);
@ -72,10 +77,10 @@ EOTEXT
} }
} }
echo phutil_console_wrap( echo phutil_console_format(
phutil_console_format( "**%s** %s\n",
"**Updated!** Your copy of arc is now up to date.\n")); pht('Updated!'),
pht('Your copy of arc is now up to date.'));
return 0; return 0;
} }