]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Don't do working copy checks for "arc amend --show"
authorepriestley <git@epriestley.com>
Sun, 23 Oct 2011 19:55:43 +0000 (12:55 -0700)
committerepriestley <git@epriestley.com>
Tue, 25 Oct 2011 06:37:47 +0000 (23:37 -0700)
Summary: See T587. Reduce the strictness of working copy checks when using
"--show", since there's a reasonable workflow where you 'arc patch' and then
'arc amend --revision X --show | git commit -a -F -' that currently won't work.
There are other ways to accomplish the same thing but this increases flexibility
overall.

Test Plan: Ran 'arc amend --show' with a dirty working copy, didn't get yelled
at.

Reviewers: jungejason, nh, tuomaspelkonen, aran

Reviewed By: nh

CC: aran, nh
Differential Revision: 1033

src/workflow/amend/ArcanistAmendWorkflow.php

index 78749f3c80bd81070dceac9b501c1460a0f0c8ce..0c16e4ba921a83408149c182ef25265386352248 100644 (file)
@@ -53,7 +53,7 @@ EOTEXT
     return array(
       'show' => array(
         'help' =>
-          "Show the amended commit message."
+          "Show the amended commit message, without modifying the working copy."
       ),
       'revision' => array(
         'param' => 'revision_id',
@@ -65,13 +65,7 @@ EOTEXT
   }
 
   public function run() {
-    if ($this->isHistoryImmutable()) {
-      throw new ArcanistUsageException(
-        "This project is marked as adhering to a conservative history ".
-        "mutability doctrine (having an immutable local history), which ".
-        "precludes amending commit messages. You can use 'arc merge' to ".
-        "merge feature branches instead.");
-    }
+    $is_show = $this->getArgument('show');
 
     $repository_api = $this->getRepositoryAPI();
     if (!($repository_api instanceof ArcanistGitAPI)) {
@@ -79,10 +73,20 @@ EOTEXT
         "You may only run 'arc amend' in a git working copy.");
     }
 
-    if ($repository_api->getUncommittedChanges()) {
-      throw new ArcanistUsageException(
-        "You have uncommitted changes in this branch. Stage and commit (or ".
-        "revert) them before proceeding.");
+    if (!$is_show) {
+      if ($this->isHistoryImmutable()) {
+        throw new ArcanistUsageException(
+          "This project is marked as adhering to a conservative history ".
+          "mutability doctrine (having an immutable local history), which ".
+          "precludes amending commit messages. You can use 'arc merge' to ".
+          "merge feature branches instead.");
+      }
+
+      if ($repository_api->getUncommittedChanges()) {
+        throw new ArcanistUsageException(
+          "You have uncommitted changes in this branch. Stage and commit (or ".
+          "revert) them before proceeding.");
+      }
     }
 
     if ($this->getArgument('revision')) {
@@ -120,7 +124,7 @@ EOTEXT
         'edit'        => false,
       ));
 
-    if ($this->getArgument('show')) {
+    if ($is_show) {
       echo $message."\n";
     } else {
       $repository_api->amendGitHeadCommit($message);