Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistFeatureWorkflow.php
<?php | <?php | ||||
/** | class ArcanistFeatureWorkflow | ||||
* Displays user's Git branches or Mercurial bookmarks. | extends ArcanistArcWorkflow { | ||||
* | |||||
* @concrete-extensible | |||||
*/ | |||||
class ArcanistFeatureWorkflow extends ArcanistWorkflow { | |||||
private $branches; | private $branches; | ||||
public function getWorkflowName() { | public function getWorkflowName() { | ||||
return 'feature'; | return 'feature'; | ||||
} | } | ||||
public function getCommandSynopses() { | public function getWorkflowArguments() { | ||||
return phutil_console_format(<<<EOTEXT | return array( | ||||
**feature** [__options__] | $this->newWorkflowArgument('view-all') | ||||
**feature** __name__ [__start__] | ->setHelp(pht('Include closed and abandoned revisions.')), | ||||
EOTEXT | $this->newWorkflowArgument('by-status') | ||||
->setParameter('status') | |||||
->setHelp(pht('Sort branches by status instead of time.')), | |||||
$this->newWorkflowArgument('output') | |||||
->setParameter('format') | |||||
->setHelp( | |||||
pht( | |||||
'With "json", show features in machine-readable JSON format.')), | |||||
$this->newWorkflowArgument('branch') | |||||
->setWildcard(true), | |||||
); | ); | ||||
} | } | ||||
public function getCommandHelp() { | public function getWorkflowInformation() { | ||||
return phutil_console_format(<<<EOTEXT | return $this->newWorkflowInformation() | ||||
Supports: git, hg | ->setSynopsis(pht('Wrapper on "git branch" or "hg bookmark".')) | ||||
->addExample(pht('**feature** [__options__]')) | |||||
->addExample(pht('**feature** __name__ [__start__]')) | |||||
->setHelp( | |||||
pht(<<<EOHELP | |||||
A wrapper on 'git branch' or 'hg bookmark'. | A wrapper on 'git branch' or 'hg bookmark'. | ||||
Without __name__, it lists the available branches and their revision | Without __name__, it lists the available branches and their revision status. | ||||
status. | |||||
With __name__, it creates or checks out a branch. If the branch | |||||
__name__ doesn't exist and is in format D123 then the branch of | |||||
revision D123 is checked out. Use __start__ to specify where the new | |||||
branch will start. Use 'arc.feature.start.default' to set the default | |||||
feature start location. | |||||
EOTEXT | |||||
); | |||||
} | |||||
public function requiresRepositoryAPI() { | |||||
return true; | |||||
} | |||||
public function getArguments() { | With __name__, it creates or checks out a branch. If the branch __name__ | ||||
return array( | doesn't exist and is in format D123 then the branch of revision D123 is | ||||
'view-all' => array( | checked out. Use __start__ to specify where the new branch will start. Use | ||||
'help' => pht('Include closed and abandoned revisions.'), | 'arc.feature.start.default' to set the default feature start location. | ||||
), | EOHELP | ||||
'by-status' => array( | )); | ||||
'help' => pht('Sort branches by status instead of time.'), | |||||
), | |||||
'output' => array( | |||||
'param' => 'format', | |||||
'support' => array( | |||||
'json', | |||||
), | |||||
'help' => pht( | |||||
"With '%s', show features in machine-readable JSON format.", | |||||
'json'), | |||||
), | |||||
'*' => 'branch', | |||||
); | |||||
} | } | ||||
public function getSupportedRevisionControlSystems() { | public function runWorkflow() { | ||||
return array('git', 'hg'); | $working_copy = $this->getWorkingCopy(); | ||||
} | |||||
public function run() { | |||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
if (!$repository_api) { | |||||
throw new PhutilArgumentUsageException( | |||||
pht( | |||||
'This command must be run in a Git or Mercurial working copy.')); | |||||
} | |||||
$names = $this->getArgument('branch'); | $names = $this->getArgument('branch'); | ||||
if ($names) { | if ($names) { | ||||
if (count($names) > 2) { | if (count($names) > 2) { | ||||
throw new ArcanistUsageException(pht('Specify only one branch.')); | throw new ArcanistUsageException(pht('Specify only one branch.')); | ||||
} | } | ||||
return $this->checkoutBranch($names); | return $this->checkoutBranch($names); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 204 Lines • Show Last 20 Lines |