From df8c0e5e25cd4138b2e6c2d900bf1d475b6cb66a Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 23 Oct 2011 12:55:43 -0700 Subject: [PATCH] Don't do working copy checks for "arc amend --show" 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 | 30 +++++++++++--------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/workflow/amend/ArcanistAmendWorkflow.php b/src/workflow/amend/ArcanistAmendWorkflow.php index 78749f3c..0c16e4ba 100644 --- a/src/workflow/amend/ArcanistAmendWorkflow.php +++ b/src/workflow/amend/ArcanistAmendWorkflow.php @@ -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);