From ed7034ab383a6776caf1ee99780f0a740ccd2475 Mon Sep 17 00:00:00 2001 From: Jason Ge Date: Wed, 23 May 2012 16:26:20 -0700 Subject: [PATCH] Fix arc ArcanistSvnHookPreCommitWorkflow 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 | 3 ++- .../hookapi/subversion/ArcanistSubversionHookAPI.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lint/engine/base/ArcanistLintEngine.php b/src/lint/engine/base/ArcanistLintEngine.php index 8d7cee4f..aed642ba 100644 --- a/src/lint/engine/base/ArcanistLintEngine.php +++ b/src/lint/engine/base/ArcanistLintEngine.php @@ -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); diff --git a/src/repository/hookapi/subversion/ArcanistSubversionHookAPI.php b/src/repository/hookapi/subversion/ArcanistSubversionHookAPI.php index 2381df43..ca0255c4 100644 --- a/src/repository/hookapi/subversion/ArcanistSubversionHookAPI.php +++ b/src/repository/hookapi/subversion/ArcanistSubversionHookAPI.php @@ -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); } -- 2.43.0