]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Tighten up "arc land"
authorBob Trahan <bob.trahan@gmail.com>
Thu, 5 Sep 2013 19:45:59 +0000 (12:45 -0700)
committerBob Trahan <bob.trahan@gmail.com>
Thu, 5 Sep 2013 19:45:59 +0000 (12:45 -0700)
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
src/workflow/ArcanistPatchWorkflow.php

index 374bd82f0a469bd8a1bbc1493c6f60e3f7f84333..714f1918b1a4ed05cfd3628d2256b4fcbbcdfbca 100644 (file)
@@ -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) {
+    // these commands can fail legitimately (e.g. commit hooks)
+    try {
+      if ($this->isGit) {
         $repository_api->execxLocal(
-          'commit --logfile %s',
+          '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.
-    try {
+      // 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);
index 51775c11e633decae5a9b28763efab563f54317c..907e97f946b45ca53a29a399238225cb56c242bd 100644 (file)
@@ -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()) {