From: epriestley Date: Wed, 11 Jul 2012 23:55:11 +0000 (-0700) Subject: Support an 'editor' config in arc X-Git-Tag: conduit-6~205 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=1b4205c1a1b6c665ab7af01b80ba438628adb383;p=arcanist.git Support an 'editor' config in arc Summary: See D2955. Allow "arc set-config editor ..." to override all other editor settings. Test Plan: Ran "arc set-config editor 'mate -w'", am typing this in textmate. Reviewers: btrahan, ezfoxie Reviewed By: btrahan CC: aran Maniphest Tasks: T1309 Differential Revision: https://secure.phabricator.com/D2956 --- diff --git a/src/workflow/ArcanistBaseWorkflow.php b/src/workflow/ArcanistBaseWorkflow.php index 222d1255..4fe084f8 100644 --- a/src/workflow/ArcanistBaseWorkflow.php +++ b/src/workflow/ArcanistBaseWorkflow.php @@ -1276,4 +1276,15 @@ abstract class ArcanistBaseWorkflow { return $value; } + protected function newInteractiveEditor($text) { + $editor = new PhutilInteractiveEditor($text); + + $preferred = $this->getWorkingCopy()->getConfigFromAnySource('editor'); + if ($preferred) { + $editor->setPreferredEditor($preferred); + } + + return $editor; + } + } diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 4fe85c99..b8aab48a 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -447,7 +447,7 @@ EOTEXT $should_edit = $this->getArgument('edit'); if ($should_edit) { - $remote_corpus = id(new PhutilInteractiveEditor($remote_corpus)) + $remote_corpus = $this->newInteractiveEditor($remote_corpus) ->setName('differential-edit-revision-info') ->editInteractively(); } @@ -1412,7 +1412,7 @@ EOTEXT if ($first && $this->getArgument('verbatim') && !$template_is_default) { $new_template = $template; } else { - $new_template = id(new PhutilInteractiveEditor($template)) + $new_template = $this->newInteractiveEditor($template) ->setName('new-commit') ->editInteractively(); } @@ -1599,7 +1599,7 @@ EOTEXT "# $ arc diff --create\n". "\n"; - $comments = id(new PhutilInteractiveEditor($template)) + $comments = $this->newInteractiveEditor($template) ->setName('differential-update-comments') ->editInteractively(); diff --git a/src/workflow/ArcanistPatchWorkflow.php b/src/workflow/ArcanistPatchWorkflow.php index 771dfb22..5240c320 100644 --- a/src/workflow/ArcanistPatchWorkflow.php +++ b/src/workflow/ArcanistPatchWorkflow.php @@ -658,7 +658,7 @@ EOTEXT $prompt_message. "\n"; - $commit_message = id(new PhutilInteractiveEditor($template)) + $commit_message = $this->newInteractiveEditor($template) ->setName('arcanist-patch-commit-message') ->editInteractively();