]> khamidou — GitHub mirrors - arcanist.git/commitdiff
make arc commit work on windows with multiline messages
authorBob Trahan <bob.trahan@gmail.com>
Wed, 3 Oct 2012 21:54:43 +0000 (14:54 -0700)
committerBob Trahan <bob.trahan@gmail.com>
Wed, 3 Oct 2012 21:54:43 +0000 (14:54 -0700)
Summary: cd && cmd won't work so use chdir; -m $multiline_message won't work so use -F $tmp_file

Test Plan: this is actually un-tested at the moment.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T1617

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

src/workflow/ArcanistCommitWorkflow.php

index 8fce0a972a6c02ef937328671826afa86ccf84eb..85e18fc33199a3b3de738e8ba0426c53eef2b680 100644 (file)
@@ -153,17 +153,17 @@ EOTEXT
 
     $files = $this->getCommitFileList($revision);
 
-    $files = implode(' ', array_map('escapeshellarg', $files));
-    $message = escapeshellarg($message);
-    $root = escapeshellarg($repository_api->getPath());
+    $tmp_file = new TempFile();
+    Filesystem::writeFile($tmp_file, $message);
 
-    $lang = $this->getSVNLangEnvVar();
+    $command = $this->getSVNCommitCommand();
+    chdir($repository_api->getPath());
 
-    // Specify LANG explicitly so that UTF-8 commit messages don't break
-    // subversion.
-    $command = "(cd {$root} && LANG={$lang} svn commit {$files} -m {$message})";
-
-    $err = phutil_passthru('%C', $command);
+    $err = phutil_passthru(
+      $command,
+      $files,
+      $tmp_file
+    );
 
     if ($err) {
       throw new Exception("Executing 'svn commit' failed!");
@@ -289,7 +289,8 @@ EOTEXT
    *   svn: warning: environment variable LANG is en_US.utf8
    *   svn: warning: please check that your locale name is correct
    *
-   * For example, is happens on my 10.6.7 machine with Subversion 1.6.15.
+   * For example, it happens on epriestley's Mac (10.6.7) with
+   * Subversion 1.6.15.
    */
   private function getSVNLangEnvVar() {
     $locale = 'en_US.utf8';
@@ -306,6 +307,16 @@ EOTEXT
     return $locale;
   }
 
+  private function getSVNCommitCommand() {
+    $command = 'svn commit %Ls --encoding utf-8 -F %s';
+    // make sure to specify LANG on non-windows systems to surpress any fancy
+    // warnings; see @{method:getSVNLangEnvVar}.
+    if (!phutil_is_windows()) {
+      $command = 'LANG='.$this->getSVNLangEnvVar().' '.$command;
+    }
+    return $command;
+  }
+
   private function runSanityChecks(array $revision) {
     $repository_api = $this->getRepositoryAPI();
     $revision_id = $revision['id'];