]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix arc ArcanistSvnHookPreCommitWorkflow
authorJason Ge <jungejason@fb.com>
Wed, 23 May 2012 23:26:20 +0000 (16:26 -0700)
committerJason Ge <jungejason@fb.com>
Wed, 23 May 2012 23:29:27 +0000 (16:29 -0700)
Summary:
there are two problems making the ArcanistSvnHookPreCommitWorkflow not working.

  - pathExists($path) will always return false because it hasn't loaded the path yet. Because of this, PhutilLintEngine will unset the path at https://secure.phabricator.com/diffusion/ARC/browse/master/src/lint/engine/phutil/PhutilLintEngine.php;032b9b30b0721c3f$46, so ArcanistSvnHookPreCommitWorkflow will have no path to lint against and never detects a problem.
  - In ArcanistSubversionHookAPI::getCurrentFileData(), the $path is already the full path in svnroot (path got from https://secure.phabricator.com/diffusion/ARC/browse/master/src/workflow/svn-hook-pre-commit/ArcanistSvnHookPreCommitWorkflow.php;032b9b30b0721c3f$72). Prepending the project root to it will make the file path to be wrong so that the file content is empty. Again, ArcanistSvnHookPreCommitWorkflow never detects a problem.

Test Plan:
changed --transaction to --revision in related code and manually ran the following command. It detected the syntaxt error correctly. 558937 is a revision with syntax error.

/usr/local/bin/php -f /home/jungejason/nfs_devtools/arcanist/bin/arc svn-hook-pre-commit     --load-phutil-library=/tmp/testwww/www/lib/arcanist --load-phutil-library=/home/jungejason/nfs_devtools/facebook/src /svnroot 558937 2>&1

Reviewers: epriestley, nh

Reviewed By: nh

CC: aran, Girish, Koolvin
Differential Revision: https://secure.phabricator.com/D2485

src/lint/engine/base/ArcanistLintEngine.php
src/repository/hookapi/subversion/ArcanistSubversionHookAPI.php

index 8d7cee4f4b11e4784251fe5b084c44ad9372823a..aed642ba54a38294b9d2161df3e5b39fabae1581 100644 (file)
@@ -141,7 +141,8 @@ abstract class ArcanistLintEngine {
 
   public function pathExists($path) {
     if ($this->getCommitHookMode()) {
-      return (idx($this->fileData, $path) !== null);
+      $file_data = $this->loadData($path);
+      return ($file_data !== null);
     } else {
       $disk_path = $this->getFilePathOnDisk($path);
       return Filesystem::pathExists($disk_path);
index 2381df43f42a71c34848a16cff649e3c452ddebb..ca0255c42dcaf4d8b807c33cae7e72550f4f3793 100644 (file)
@@ -36,7 +36,7 @@ final class ArcanistSubversionHookAPI extends ArcanistHookAPI {
       'svnlook cat --transaction %s %s %s',
       $this->transaction,
       $this->repository,
-      $this->root . "/$path");
+      $path);
 
     return ($err? null : $file);
   }