Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistUpgradeWorkflow.php
| Show All 23 Lines | EOTEXT | ||||
| ); | ); | ||||
| } | } | ||||
| public function run() { | public function run() { | ||||
| $roots = array( | $roots = array( | ||||
| 'arcanist' => dirname(phutil_get_library_root('arcanist')), | 'arcanist' => dirname(phutil_get_library_root('arcanist')), | ||||
| ); | ); | ||||
| $supported_branches = array( | |||||
| 'master', | |||||
| 'stable', | |||||
| 'experimental', | |||||
| ); | |||||
| $supported_branches = array_fuse($supported_branches); | |||||
| foreach ($roots as $lib => $root) { | foreach ($roots as $lib => $root) { | ||||
| echo phutil_console_format( | echo phutil_console_format( | ||||
| "%s\n", | "%s\n", | ||||
| pht('Upgrading %s...', $lib)); | pht('Upgrading %s...', $lib)); | ||||
| $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); | ||||
| Show All 30 Lines | foreach ($roots as $lib => $root) { | ||||
| ->addList($list) | ->addList($list) | ||||
| ->draw(); | ->draw(); | ||||
| throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
| pht('`arc upgrade` can only upgrade clean working copies.')); | pht('`arc upgrade` can only upgrade clean working copies.')); | ||||
| } | } | ||||
| $branch_name = $repository->getBranchName(); | $branch_name = $repository->getBranchName(); | ||||
| if ($branch_name != 'master' && $branch_name != 'stable') { | if (!isset($supported_branches[$branch_name])) { | ||||
| throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
| pht( | pht( | ||||
| "%s must be on either branch '%s' or '%s' to be automatically ". | 'Library "%s" (in "%s") is on branch "%s", but this branch is '. | ||||
| "upgraded. ". | 'not supported for automatic upgrades. Supported branches are: '. | ||||
| "This copy of %s (in '%s') is on branch '%s'.", | '%s.', | ||||
| $lib, | |||||
| 'master', | |||||
| 'stable', | |||||
| $lib, | $lib, | ||||
| $root, | $root, | ||||
| $branch_name)); | $branch_name, | ||||
| implode(', ', array_keys($supported_branches)))); | |||||
| } | } | ||||
| chdir($root); | chdir($root); | ||||
| try { | try { | ||||
| execx('git pull --rebase'); | execx('git pull --rebase'); | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| // If we failed, try to go back to the old state, then throw the | // If we failed, try to go back to the old state, then throw the | ||||
| Show All 14 Lines | |||||