public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
- **land** [__options__] __branch__ [--onto __master__]
+ **land** [__options__] [__branch__] [--onto __master__]
EOTEXT
);
}
Land an accepted change (currently sitting in local feature branch
__branch__) onto __master__ and push it to the remote. Then, delete
- the feature branch.
+ the feature branch. If you omit __branch__, the current branch will
+ be used.
In mutable repositories, this will perform a --squash merge (the
entire branch will be represented by one commit on __master__). In
}
public function run() {
+ $repository_api = $this->getRepositoryAPI();
+ if (!($repository_api instanceof ArcanistGitAPI)) {
+ throw new ArcanistUsageException("'arc land' only supports git.");
+ }
+
$branch = $this->getArgument('branch');
+ if (empty($branch)) {
+ $branch = $repository_api->getBranchName();
+ if ($branch) {
+ echo "Landing current branch '{$branch}'.\n";
+ $branch = array($branch);
+ }
+ }
+
if (count($branch) !== 1) {
throw new ArcanistUsageException(
"Specify exactly one branch to land changes from.");
$use_squash = !$this->isHistoryImmutable();
}
- $repository_api = $this->getRepositoryAPI();
- if (!($repository_api instanceof ArcanistGitAPI)) {
- throw new ArcanistUsageException("'arc land' only supports git.");
- }
-
list($err) = $repository_api->execManualLocal(
'rev-parse --verify %s',
$branch);
$cur = idx($argv, $pos, '');
$any_match = false;
- foreach ($output as $possible) {
- if (!strncmp($possible, $cur, strlen($cur))) {
- $any_match = true;
+
+ if (strlen($cur)) {
+ foreach ($output as $possible) {
+ if (!strncmp($possible, $cur, strlen($cur))) {
+ $any_match = true;
+ }
}
}
if (!$any_match && isset($arguments['*'])) {
- // TODO: the '*' specifier should probably have more details about
- // whether or not it is a list of files. Since it almost always is in
- // practice, assume FILE for now.
- echo "FILE\n";
- } else {
- echo implode(' ', $output)."\n";
+ // TODO: This is mega hacktown but something else probably breaks
+ // if we use a rich argument specification; fix it when we move to
+ // PhutilArgumentParser since everything will need to be tested then
+ // anyway.
+ if ($arguments['*'] == 'branch' && isset($repository_api)) {
+ $branches = $repository_api->getAllBranches();
+ $branches = ipull($branches, 'name');
+ $output = $branches;
+ } else {
+ $output = array("FILE");
+ }
}
+
+ echo implode(' ', $output)."\n";
+
return 0;
}
}