]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Check both UNIX- and Windows-style paths from linter output
authorAlex Vandiver <alexmv@dropbox.com>
Tue, 20 Sep 2016 21:48:06 +0000 (14:48 -0700)
committerAlex Vandiver <alexmv@dropbox.com>
Wed, 21 Sep 2016 21:29:42 +0000 (14:29 -0700)
Summary:
Paths are passed into linters using UNIX-style slashes (/), as returned from the version control system; however,
`Filesystem::readablePath` swaps them to Windows-style (\) on
Windows when storing the names of the files with lint messages.  This causes no lint message's path to match the set of
changed files, and thus no lint warnings are ever produced.

If a lint message's file is not found using the provided filename, also try looking up the UNIX-style filename, on Windows when determining if a lint mesage is "relevant."

Fixes T11248.

Test Plan: Ran `arc lint` on Windows.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley

Maniphest Tasks: T11248

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

src/lint/engine/ArcanistLintEngine.php

index 0bef3e0a8e2b2ea7afd6ac3f40cfdda04a8338a0..ee80e6c2dafbee740515afb731639084d0dc56cd 100644 (file)
@@ -343,7 +343,18 @@ abstract class ArcanistLintEngine extends Phobject {
       $path = idx($location, 'path', $message->getPath());
 
       if (!array_key_exists($path, $this->changedLines)) {
-        continue;
+        if (phutil_is_windows()) {
+          // We try checking the UNIX path form as well, on Windows.  Linters
+          // store noramlized paths, which use the Windows-style "\" as a
+          // delimiter; as such, they don't match the UNIX-style paths stored
+          // in changedLines, which come from the VCS.
+          $path = str_replace('\\', '/', $path);
+          if (!array_key_exists($path, $this->changedLines)) {
+            continue;
+          }
+        } else {
+          continue;
+        }
       }
 
       $changed = $this->getPathChangedLines($path);