зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1896514 - Make `mach lint` accommodate Windows drive case differences. r=ahal
We hand-roll to avoid `os.path.realpath` invoking potentially expensive filesystem APIs. Differential Revision: https://phabricator.services.mozilla.com/D210230
This commit is contained in:
Родитель
bf4b53c4f4
Коммит
19723a8f10
|
@ -3,10 +3,13 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from mozpack import path as mozpath
|
||||
from mozpack.files import FileFinder
|
||||
|
||||
_is_windows = sys.platform == "cygwin" or (sys.platform == "win32" and os.sep == "\\")
|
||||
|
||||
|
||||
class FilterPath(object):
|
||||
"""Helper class to make comparing and matching file paths easier."""
|
||||
|
@ -64,6 +67,13 @@ class FilterPath(object):
|
|||
if len(parts_a) > len(parts_b):
|
||||
return False
|
||||
|
||||
if _is_windows and parts_a:
|
||||
# Normalize case of drive letters, without invoking the file system.
|
||||
if parts_a[0].endswith(":"):
|
||||
parts_a[0] = parts_a[0].upper()
|
||||
if parts_b[0].endswith(":"):
|
||||
parts_b[0] = parts_b[0].upper()
|
||||
|
||||
for i, part in enumerate(parts_a):
|
||||
if part != parts_b[i]:
|
||||
return False
|
||||
|
|
Загрузка…
Ссылка в новой задаче