]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Use readable path in lint messages
authorvrana <jakubv@fb.com>
Tue, 7 Feb 2012 17:57:26 +0000 (09:57 -0800)
committervrana <jakubv@fb.com>
Tue, 7 Feb 2012 18:22:50 +0000 (10:22 -0800)
Summary:
Some linters return absolute path.
It causes separate lint messages for the same file.
Also lint messages aren't properly bound in Phabricator.

I've preferred changing addLintMessage() to fixing all linters because it is
more robust.

Test Plan: arc lint of a file with lint problem from linter using absolute paths

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1589

src/lint/linter/base/ArcanistLinter.php
src/lint/linter/base/__init__.php

index 366c0a69d73fe1412b3434fc749eb690f5c96a46..e5e2cfe5f72d471549bd73516b565090ff4033fb 100644 (file)
@@ -114,6 +114,11 @@ abstract class ArcanistLinter {
   }
 
   protected function addLintMessage(ArcanistLintMessage $message) {
+    if (!$this->getEngine()->getCommitHookMode()) {
+      $root = $this->getEngine()->getWorkingCopy()->getProjectRoot();
+      $path = Filesystem::resolvePath($message->getPath(), $root);
+      $message->setPath(Filesystem::readablePath($path, $root));
+    }
     $this->messages[] = $message;
     return $message;
   }
index ade0834a16af86cb34d4173edb6ec589aaedfa6b..1b364bf590758e63ecc8801daafcc9172c1f8fe8 100644 (file)
@@ -9,5 +9,7 @@
 phutil_require_module('arcanist', 'lint/message');
 phutil_require_module('arcanist', 'lint/severity');
 
+phutil_require_module('phutil', 'filesystem');
+
 
 phutil_require_source('ArcanistLinter.php');