File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""Module with additional types used by the index"""
22
33from binascii import b2a_hex
4+ from pathlib import Path
45
56from .util import pack , unpack
67from git .objects import Blob
@@ -51,11 +52,12 @@ def __init__(self, paths: Sequence[PathLike]) -> None:
5152 self .paths = paths
5253
5354 def __call__ (self , stage_blob : Tuple [StageType , Blob ]) -> bool :
54- path : str = str (stage_blob [1 ].path )
55- for p in self .paths :
56- if path .startswith (str (p )):
55+ blob_pathlike : Pathlike = stage_blob [1 ].path
56+ blob_path : Path = blob_pathlike if isinstance (blob_pathlike , Path ) else Path (blob_pathlike )
57+ for pathlike in self .paths :
58+ path : Path = pathlike if isinstance (pathlike , Path ) else Path (pathlike )
59+ if path .is_relative_to (blob_path ):
5760 return True
58- # END for each path in filter paths
5961 return False
6062
6163
You can’t perform that action at this time.
0 commit comments