From 02f111ba0bea197fe086ab80be341745bca5af31 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 26 Jan 2012 17:59:42 -0800 Subject: [PATCH] Print out recovery command before running "git branch -D" in "arc land" 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 | 11 +++++++++++ src/workflow/land/__init__.php | 1 + 2 files changed, 12 insertions(+) diff --git a/src/workflow/land/ArcanistLandWorkflow.php b/src/workflow/land/ArcanistLandWorkflow.php index 59123fa6..f6fd53cc 100644 --- a/src/workflow/land/ArcanistLandWorkflow.php +++ b/src/workflow/land/ArcanistLandWorkflow.php @@ -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(), diff --git a/src/workflow/land/__init__.php b/src/workflow/land/__init__.php index eadd9ad0..7db219ca 100644 --- a/src/workflow/land/__init__.php +++ b/src/workflow/land/__init__.php @@ -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'); -- 2.43.0