1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-25 15:00:57 +01:00

arc land: add --delete-remote, raise an error for landing a branch onto itself

Summary:
  - Allow users to delete the remote copy of a feature branch as well as the local one, for workflows that push feature branches. We test if the remote exists before trying to delete it.
  - Raise a better warning when you misuse "arc land".
  - I also wrote some documentation about this, see next diff.

Test Plan:
  - Tried to land a branch onto itself.
  - Ran "arc land --delete-remote" on feature branches with and without remote feature branches.

Reviewers: aurelijus, btrahan

Reviewed By: aurelijus

CC: aran

Maniphest Tasks: T1204

Differential Revision: https://secure.phabricator.com/D2445
This commit is contained in:
epriestley 2012-05-10 12:14:53 -07:00
parent 9d5c5f6310
commit 86ead1b8f1

View file

@ -97,6 +97,13 @@ EOTEXT
'merge' => '--merge and --squash are conflicting merge strategies.', 'merge' => '--merge and --squash are conflicting merge strategies.',
), ),
), ),
'delete-remote' => array(
'help' => 'Delete the feature branch in the remote after '.
'landing it.',
'conflicts' => array(
'keep-branch' => true,
),
),
'revision' => array( 'revision' => array(
'param' => 'id', 'param' => 'id',
'help' => 'Use the message from a specific revision, rather than '. 'help' => 'Use the message from a specific revision, rather than '.
@ -134,6 +141,14 @@ EOTEXT
$remote = $this->getArgument('remote', 'origin'); $remote = $this->getArgument('remote', 'origin');
$onto = $this->getArgument('onto', $onto_default); $onto = $this->getArgument('onto', $onto_default);
if ($onto == $branch) {
throw new ArcanistUsageException(
"You can not land a branch onto itself -- you are trying to land ".
"'{$branch}' onto '{$onto}'. For more information on how to push ".
"changes, see 'Pushing and Closing Revisions' in ".
"'Arcanist User Guide: arc diff' in the documentation.");
}
if ($this->getArgument('merge')) { if ($this->getArgument('merge')) {
$use_squash = false; $use_squash = false;
} else if ($this->getArgument('squash')) { } else if ($this->getArgument('squash')) {
@ -327,6 +342,29 @@ EOTEXT
$repository_api->execxLocal( $repository_api->execxLocal(
'branch -D %s', 'branch -D %s',
$branch); $branch);
if ($this->getArgument('delete-remote')) {
list($err, $ref) = $repository_api->execManualLocal(
'rev-parse --verify %s/%s',
$remote,
$branch);
if ($err) {
echo "No remote feature branch to clean up.\n";
} else {
// NOTE: In Git, you delete a remote branch by pushing it with a
// colon in front of its name:
//
// git push <remote> :<branch>
echo "Cleaning up remote feature branch...\n";
$repository_api->execxLocal(
'push %s :%s',
$remote,
$branch);
}
}
} }
// If we were on some branch A and the user ran "arc land B", switch back // If we were on some branch A and the user ran "arc land B", switch back