]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Explain how to move forward or backward from `arc land --hold`
authorepriestley <git@epriestley.com>
Sun, 13 Dec 2015 11:08:06 +0000 (03:08 -0800)
committerepriestley <git@epriestley.com>
Sun, 13 Dec 2015 16:19:04 +0000 (08:19 -0800)
Summary: Fixes T9973. When users run `arc land --hold`, give them the commands to move forward (push) or backward (checkout the branch/tag/commit they were on) and be explicit that branches have not changed.

Test Plan: Ran `arc land --hold`, got lots of explanatory text.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9973

Differential Revision: https://secure.phabricator.com/D14762

src/land/ArcanistGitLandEngine.php

index 7256b05021e920ba6b9e38039d8c60fbff820a44..068124d0710b4f963245c3d87e1b7fb502197dd2 100644 (file)
@@ -29,9 +29,7 @@ final class ArcanistGitLandEngine
       $this->updateWorkingCopy();
 
       if ($this->getShouldHold()) {
-        $this->writeInfo(
-          pht('HOLD'),
-          pht('Holding change locally, it has not been pushed.'));
+        $this->didHoldChanges();
       } else {
         $this->pushChange();
         $this->reconcileLocalState();
@@ -542,4 +540,41 @@ final class ArcanistGitLandEngine
     );
   }
 
+  private function didHoldChanges() {
+    $this->writeInfo(
+      pht('HOLD'),
+      pht(
+        'Holding change locally, it has not been pushed.'));
+
+    $push_command = csprintf(
+      '$ git push -- %R %R:%R',
+      $this->getTargetRemote(),
+      $this->mergedRef,
+      $this->getTargetOnto());
+
+    $restore_command = csprintf(
+      '$ git checkout %R --',
+      $this->localRef);
+
+    echo tsprintf(
+      "\n%s\n\n".
+      "%s\n\n".
+      "    %s\n\n".
+      "%s\n\n".
+      "    %s\n\n".
+      "%s\n",
+      pht(
+        'This local working copy now contains the merged changes in a '.
+        'detached state.'),
+      pht('You can push the changes manually with this command:'),
+      $push_command,
+      pht(
+        'You can go back to how things were before you ran `arc land` with '.
+        'this command:'),
+      $restore_command,
+      pht(
+        'Local branches have not been changed, and are still in exactly the '.
+        'same state as before.'));
+  }
+
 }