From 174d11ec360011ece8d323984b6fce9ca7b43b8b Mon Sep 17 00:00:00 2001 From: derAnfaenger Date: Wed, 27 Sep 2017 11:11:52 +0200 Subject: [PATCH] lister: Make excluding directories work on Windows. --- tools/server_lib/lister.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/server_lib/lister.py b/tools/server_lib/lister.py index 6e8e547..3b82026 100755 --- a/tools/server_lib/lister.py +++ b/tools/server_lib/lister.py @@ -3,7 +3,6 @@ from __future__ import print_function from __future__ import absolute_import import os -from os.path import abspath import sys import subprocess import re @@ -54,7 +53,7 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False, If ftypes is [], all files are included. use_shebang - Determine file type of extensionless files from their shebang. modified_only - Only include files which have been modified. - exclude - List of paths to be excluded, relative to repository root. + exclude - List of files or directories to be excluded, relative to repository root. group_by_ftype - If True, returns a dict of lists keyed by file type. If False, returns a flat list of files. extless_only - Only include extensionless files in output. @@ -66,7 +65,7 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False, # sys.argv as str, so that battle is already lost. Settle for hoping # everything is UTF-8. repository_root = subprocess.check_output(['git', 'rev-parse', '--show-toplevel']).strip().decode('utf-8') - exclude_abspaths = [os.path.normpath(os.path.join(repository_root, fpath)) for fpath in exclude] + exclude_abspaths = [os.path.abspath(os.path.join(repository_root, fpath)) for fpath in exclude] cmdline = ['git', 'ls-files'] + targets if modified_only: @@ -84,8 +83,8 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False, ext = os.path.splitext(fpath)[1] if extless_only and ext: continue - absfpath = abspath(fpath) - if any(absfpath == expath or absfpath.startswith(expath + '/') + absfpath = os.path.abspath(fpath) + if any(absfpath == expath or absfpath.startswith(os.path.abspath(expath) + os.sep) for expath in exclude_abspaths): continue