]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Check for cleanWorkingCopy in sanityCheck, and execute sanityCheck first
authorKevin Deggelman <kevin@tenxer.com>
Fri, 3 Feb 2012 22:04:41 +0000 (14:04 -0800)
committerepriestley <git@epriestley.com>
Fri, 3 Feb 2012 22:05:53 +0000 (14:05 -0800)
Summary:
  - Renamed sanityCheckPatch to sanityCheck
  - Move check for clean working copy into sanityCheck
  - Execute sanityCheck before executing any other command

Test Plan:
  - Run ##arc patch <revision id>## from a dirty working copy
and verify that a usage exception is thrown before the new branch is
created.
  - Run ##arc patch <revision id> --force## and verify that it attempts
    to create a new branch, apply, and commit the patch.
  - Then clean your working copy and verify that ##arc patch <revision
    id> works as expected

Reviewers: epriestley, btrahan

Reviewed By: btrahan

CC: aran, epriestley
Maniphest Tasks: T830, T479

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

src/workflow/patch/ArcanistPatchWorkflow.php

index 6e0dd8ce6e7e2ab8be3f78114df40b4bb0d755e2..38c89b87a92a51ee9717ce9d52d728023f66275d 100644 (file)
@@ -232,7 +232,7 @@ EOTEXT
       // no error means git rev-parse found a branch
       if (!$err) {
         echo phutil_console_format(
-          "Branch name {$proposed_name} alread exists; trying a new name.\n"
+          "Branch name {$proposed_name} already exists; trying a new name.\n"
         );
         continue;
       } else {
@@ -354,6 +354,12 @@ EOTEXT
         throw $ex;
       }
     }
+    $force = $this->getArgument('force', false);
+    if ($force) {
+      // force means don't do any sanity checks about the patch
+    } else {
+      $this->sanityCheck($bundle);
+    }
 
     // we should update the working copy before we do ANYTHING else
     if ($this->shouldUpdateWorkingCopy()) {
@@ -364,13 +370,6 @@ EOTEXT
       $this->createBranch($bundle);
     }
 
-    $force = $this->getArgument('force', false);
-    if ($force) {
-      // force means don't do any sanity checks about the patch
-    } else {
-      $this->sanityCheckPatch($bundle);
-    }
-
     $repository_api = $this->getRepositoryAPI();
     if ($repository_api instanceof ArcanistSubversionAPI) {
       $patch_err = 0;
@@ -570,12 +569,6 @@ EOTEXT
 
       return $patch_err;
     } else if ($repository_api instanceof ArcanistGitAPI) {
-      // if we're going to commit, we should make sure the working copy
-      // is clean
-      if ($this->shouldCommit()) {
-        $this->requireCleanWorkingCopy();
-      }
-
       $future = new ExecFuture(
         '(cd %s; git apply --index --reject)',
         $repository_api->getPath());
@@ -663,7 +656,10 @@ EOTEXT
   /**
    * Do the best we can to prevent PEBKAC and id10t issues.
    */
-  private function sanityCheckPatch(ArcanistBundle $bundle) {
+  private function sanityCheck(ArcanistBundle $bundle) {
+
+    // Require clean working copy
+    $this->requireCleanWorkingCopy();
 
     // Check to see if the bundle's project id matches the working copy
     // project id