From 67061480f92f5c0743a8402a34bd408341c63079 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Thu, 5 Sep 2013 12:45:59 -0700 Subject: [PATCH] Tighten up "arc land" Summary: Make sure on failure (restoreBranch()) we call `git submodule update --init --recursive` to handle all those purdy submodules. For the pushing step, wrap the push commands in the try / catch block so everything gets cleaned up nice if there's failure. BONUS - add --recursive to arc patch workflow to so nested submodules work correctly. (Crazy git users) Fixes T3407, T2945. Test Plan: I wasn't sure how to simulate a good "push" failure but I think this should work. Reviewers: epriestley Reviewed By: epriestley CC: Korvin, aran Maniphest Tasks: T2945, T3407 Differential Revision: https://secure.phabricator.com/D6885 --- src/workflow/ArcanistLandWorkflow.php | 36 ++++++++++++++------------ src/workflow/ArcanistPatchWorkflow.php | 2 +- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/workflow/ArcanistLandWorkflow.php b/src/workflow/ArcanistLandWorkflow.php index 374bd82f..714f1918 100644 --- a/src/workflow/ArcanistLandWorkflow.php +++ b/src/workflow/ArcanistLandWorkflow.php @@ -858,23 +858,23 @@ EOTEXT private function push() { $repository_api = $this->getRepositoryAPI(); - if ($this->isGit) { - $repository_api->execxLocal( - 'commit -F %s', - $this->messageFile); - } else if ($this->isHg) { - // hg rebase produces a commit earlier as part of rebase - if (!$this->useSquash) { - $repository_api->execxLocal( - 'commit --logfile %s', - $this->messageFile); - } - } - - // We dispatch this event so we can run checks on the merged revision, right - // before it gets pushed out. It's easier to do this in arc land than to - // try to hook into git/hg. + // these commands can fail legitimately (e.g. commit hooks) try { + if ($this->isGit) { + $repository_api->execxLocal( + 'commit -F %s', + $this->messageFile); + } else if ($this->isHg) { + // hg rebase produces a commit earlier as part of rebase + if (!$this->useSquash) { + $repository_api->execxLocal( + 'commit --logfile %s', + $this->messageFile); + } + } + // We dispatch this event so we can run checks on the merged revision, + // right before it gets pushed out. It's easier to do this in arc land + // than to try to hook into git/hg. $this->dispatchEvent( ArcanistEventType::TYPE_LAND_WILLPUSHREVISION, array()); @@ -1064,6 +1064,10 @@ EOTEXT $repository_api->execxLocal( 'checkout %s', $this->oldBranch); + if ($this->isGit) { + $repository_api->execxLocal( + 'submodule update --init --recursive'); + } echo phutil_console_format( "Switched back to {$this->branchType} **%s**.\n", $this->oldBranch); diff --git a/src/workflow/ArcanistPatchWorkflow.php b/src/workflow/ArcanistPatchWorkflow.php index 51775c11..907e97f9 100644 --- a/src/workflow/ArcanistPatchWorkflow.php +++ b/src/workflow/ArcanistPatchWorkflow.php @@ -694,7 +694,7 @@ EOTEXT // in case there were any submodule changes involved $repository_api->execpassthru( - 'submodule update --init'); + 'submodule update --init --recursive'); if ($this->shouldCommit()) { if ($bundle->getFullAuthor()) {