@@ -50,6 +50,7 @@ def glob(pathname):
50
50
51
51
else :
52
52
JSONDecodeError = ValueError
53
+ FileNotFoundError = OSError # pylint: disable=redefined-builtin
53
54
54
55
def glob (pathname ):
55
56
"Alias for glob.iglob(pathname)"
@@ -281,21 +282,10 @@ def isGitRepo(path):
281
282
282
283
try :
283
284
return p .exists (subp .check_output (cmd , stderr = subp .STDOUT ).decode ().strip ())
284
- except subp .CalledProcessError :
285
+ except ( subp .CalledProcessError , FileNotFoundError ) :
285
286
return False
286
287
287
288
288
- def _isGitRepo (path ):
289
- # type: (Path) -> bool
290
- "Checks if <path> is a git repository"
291
- cmd = ["git" , "-C" , path .abspath , "status" , "--short" ]
292
- try :
293
- subp .check_call (cmd , stdout = subp .PIPE , stderr = subp .STDOUT )
294
- except subp .CalledProcessError :
295
- return False
296
- return True
297
-
298
-
299
289
def _gitLsFiles (path_to_repo , recurse_submodules = False ):
300
290
# type: (Path, bool) -> Iterable[Path]
301
291
"Lists files from a git repository"
@@ -386,12 +376,6 @@ def filterGitIgnoredPaths(path_to_repo, paths):
386
376
"""
387
377
Filters out paths that are ignored by git; paths outside the repo are kept.
388
378
"""
389
- # If not on a git repo, nothing is ignored
390
- if not _isGitRepo (path_to_repo ):
391
- for path in paths :
392
- yield path
393
- return
394
-
395
379
files = set (_gitLsFiles (path_to_repo , recurse_submodules = True ))
396
380
paths = set (paths )
397
381
0 commit comments