From 9830c9316d38988b2dc283ac1a124b73bc8e6c5f Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 6 Mar 2019 10:51:37 -0800 Subject: [PATCH] Make minor correctness changes to some "arc patch" command execution Summary: Since I'm in here for PHI1083: - Add some "--" so we get correct behavior when you have a file named "master", a branch named "README.txt", etc. - Stop using "%C" unnecessarily. - Fix some untranslatable strings. Test Plan: Ran `arc patch` a couple of times, ran the variations of `git` commands to catch anything weird with "--" handling. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D20254 --- src/workflow/ArcanistPatchWorkflow.php | 29 +++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/workflow/ArcanistPatchWorkflow.php b/src/workflow/ArcanistPatchWorkflow.php index 10e4e5b1..c3fd8296 100644 --- a/src/workflow/ArcanistPatchWorkflow.php +++ b/src/workflow/ArcanistPatchWorkflow.php @@ -741,21 +741,26 @@ EOTEXT $repository_api->execPassthru('submodule update --init --recursive'); if ($this->shouldCommit()) { + $flags = array(); if ($bundle->getFullAuthor()) { - $author_cmd = csprintf('--author=%s', $bundle->getFullAuthor()); - } else { - $author_cmd = ''; + $flags[] = csprintf('--author=%s', $bundle->getFullAuthor()); } $commit_message = $this->getCommitMessage($bundle); + $future = $repository_api->execFutureLocal( - 'commit -a %C -F - --no-verify', - $author_cmd); + 'commit -a %Ls -F - --no-verify', + $flags); $future->write($commit_message); $future->resolvex(); - $verb = pht('committed'); + + $this->writeOkay( + pht('COMMITTED'), + pht('Successfully committed patch.')); } else { - $verb = pht('applied'); + $this->writeOkay( + pht('APPLIED'), + pht('Successfully applied patch.')); } if ($this->canBranch() && @@ -765,18 +770,18 @@ EOTEXT // See PHI1083 and PHI648. Synchronize submodule state after mutating // the working copy. - $repository_api->execxLocal('checkout %s', $original_branch); + $repository_api->execxLocal('checkout %s --', $original_branch); $repository_api->execPassthru('submodule update --init --recursive'); $ex = null; try { - $repository_api->execxLocal('cherry-pick %s', $new_branch); + $repository_api->execxLocal('cherry-pick -- %s', $new_branch); $repository_api->execPassthru('submodule update --init --recursive'); } catch (Exception $ex) { // do nothing } - $repository_api->execxLocal('branch -D %s', $new_branch); + $repository_api->execxLocal('branch -D -- %s', $new_branch); if ($ex) { echo phutil_console_format( @@ -786,10 +791,6 @@ EOTEXT } } - echo phutil_console_format( - "** %s ** %s\n", - pht('OKAY'), - pht('Successfully %s patch.', $verb)); } else if ($repository_api instanceof ArcanistMercurialAPI) { $future = $repository_api->execFutureLocal('import --no-commit -'); $future->write($bundle->toGitPatch());