mirror of https://github.com/zulip/zulip.git
Fix exclude startegy in tools/lister.py.
Previously lister.py used to check whether the exclude path is a substring of a path being considered. So it would fail when the exclude path is an absolute path or uses '..' or '.'.
This commit is contained in:
parent
508a080e08
commit
bd63caed96
|
@ -1,8 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
from os.path import abspath
|
||||
import sys
|
||||
import subprocess
|
||||
import re
|
||||
|
@ -72,9 +73,10 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False,
|
|||
for fpath in files:
|
||||
# this will take a long time if exclude is very large
|
||||
in_exclude = False
|
||||
absfpath = abspath(fpath)
|
||||
for expath in exclude:
|
||||
expath = expath.rstrip('/')
|
||||
if fpath == expath or fpath.startswith(expath + '/'):
|
||||
expath = abspath(expath.rstrip('/'))
|
||||
if absfpath == expath or absfpath.startswith(expath + '/'):
|
||||
in_exclude = True
|
||||
if in_exclude:
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue