3
3
from __future__ import absolute_import
4
4
5
5
import os
6
- from os .path import abspath
7
6
import sys
8
7
import subprocess
9
8
import re
@@ -54,7 +53,7 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False,
54
53
If ftypes is [], all files are included.
55
54
use_shebang - Determine file type of extensionless files from their shebang.
56
55
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.
58
57
group_by_ftype - If True, returns a dict of lists keyed by file type.
59
58
If False, returns a flat list of files.
60
59
extless_only - Only include extensionless files in output.
@@ -66,7 +65,7 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False,
66
65
# sys.argv as str, so that battle is already lost. Settle for hoping
67
66
# everything is UTF-8.
68
67
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 ]
70
69
71
70
cmdline = ['git' , 'ls-files' ] + targets
72
71
if modified_only :
@@ -84,8 +83,8 @@ def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False,
84
83
ext = os .path .splitext (fpath )[1 ]
85
84
if extless_only and ext :
86
85
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 )
89
88
for expath in exclude_abspaths ):
90
89
continue
91
90
0 commit comments