Skip to content

Commit 174d11e

Browse files
committed
lister: Make excluding directories work on Windows.
1 parent 9ddb551 commit 174d11e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tools/server_lib/lister.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import absolute_import
44

55
import os
6-
from os.path import abspath
76
import sys
87
import subprocess
98
import re
@@ -54,7 +53,7 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False,
5453
If ftypes is [], all files are included.
5554
use_shebang - Determine file type of extensionless files from their shebang.
5655
modified_only - Only include files which have been modified.
57-
exclude - List of paths to be excluded, relative to repository root.
56+
exclude - List of files or directories to be excluded, relative to repository root.
5857
group_by_ftype - If True, returns a dict of lists keyed by file type.
5958
If False, returns a flat list of files.
6059
extless_only - Only include extensionless files in output.
@@ -66,7 +65,7 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False,
6665
# sys.argv as str, so that battle is already lost. Settle for hoping
6766
# everything is UTF-8.
6867
repository_root = subprocess.check_output(['git', 'rev-parse', '--show-toplevel']).strip().decode('utf-8')
69-
exclude_abspaths = [os.path.normpath(os.path.join(repository_root, fpath)) for fpath in exclude]
68+
exclude_abspaths = [os.path.abspath(os.path.join(repository_root, fpath)) for fpath in exclude]
7069

7170
cmdline = ['git', 'ls-files'] + targets
7271
if modified_only:
@@ -84,8 +83,8 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False,
8483
ext = os.path.splitext(fpath)[1]
8584
if extless_only and ext:
8685
continue
87-
absfpath = abspath(fpath)
88-
if any(absfpath == expath or absfpath.startswith(expath + '/')
86+
absfpath = os.path.abspath(fpath)
87+
if any(absfpath == expath or absfpath.startswith(os.path.abspath(expath) + os.sep)
8988
for expath in exclude_abspaths):
9089
continue
9190

0 commit comments

Comments
 (0)