]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Print out recovery command before running "git branch -D" in "arc land"
authorepriestley <git@epriestley.com>
Fri, 27 Jan 2012 01:59:42 +0000 (17:59 -0800)
committerepriestley <git@epriestley.com>
Fri, 27 Jan 2012 01:59:42 +0000 (17:59 -0800)
Summary: You can get this out of reflog, but we can easily just give you the
command in case you want to undo the -D.

Test Plan: Ran "arc land --hold" on this branch, used recovery command to
recover it.

Reviewers: cpiro, btrahan, jungejason

Reviewed By: cpiro

CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1504

src/workflow/land/ArcanistLandWorkflow.php
src/workflow/land/__init__.php

index 59123fa6648d8a4ef358aa7f936f56a9132f9522..f6fd53cc88081704508971f441d8fb37024722c0 100644 (file)
@@ -261,7 +261,18 @@ EOTEXT
     }
 
     if (!$this->getArgument('keep-branch')) {
+      list($ref) = execx(
+        '(cd %s && git rev-parse --verify %s)',
+        $repository_api->getPath(),
+        $branch);
+      $ref = trim($ref);
+      $recovery_command = csprintf(
+        'git checkout -b %s %s',
+        $branch,
+        $ref);
+
       echo "Cleaning up feature branch...\n";
+      echo "(Use `{$recovery_command}` if you want it back.)\n";
       execx(
         '(cd %s && git branch -D %s)',
         $repository_api->getPath(),
index eadd9ad0d104e6a5316ce63bdd8976ebc86ddd0e..7db219ca618c69707c41d05696aaa9bf226797ea 100644 (file)
@@ -14,6 +14,7 @@ phutil_require_module('arcanist', 'workflow/base');
 phutil_require_module('phutil', 'console');
 phutil_require_module('phutil', 'future/exec');
 phutil_require_module('phutil', 'utils');
+phutil_require_module('phutil', 'xsprintf/csprintf');
 
 
 phutil_require_source('ArcanistLandWorkflow.php');