mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1612115 - [mozlint] Fix an error in the path filtering logic, r=linter-reviewers,sylvestre CLOSED TREE
Essentially: FilterPath("docs").contains("docshell") was returning True because "docshell" startswith "docs". Differential Revision: https://phabricator.services.mozilla.com/D64661 --HG-- extra : source : 10f69335c6f5779522b16c3376fc78147e4a3ce0 extra : histedit_source : 7577a814e2cdf6168cd88460c42e4472dfb8f734
This commit is contained in:
parent
a1bab87650
commit
8f84b09e44
@ -57,9 +57,16 @@ class FilterPath(object):
|
||||
a = os.path.abspath(self.path)
|
||||
b = os.path.normpath(os.path.abspath(other))
|
||||
|
||||
if b.startswith(a):
|
||||
return True
|
||||
return False
|
||||
parts_a = a.split(os.sep)
|
||||
parts_b = b.split(os.sep)
|
||||
|
||||
if len(parts_a) > len(parts_b):
|
||||
return False
|
||||
|
||||
for i, part in enumerate(parts_a):
|
||||
if part != parts_b[i]:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.path)
|
||||
|
@ -65,6 +65,12 @@ TEST_CASES = (
|
||||
'expected': ['subdir1'],
|
||||
'expected_exclude': ['subdir1/subdir3'],
|
||||
},
|
||||
{
|
||||
'paths': ['docshell'],
|
||||
'include': ['docs'],
|
||||
'exclude': [],
|
||||
'expected': [],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user