File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import argparse
66import os
77import plistlib
8+ from pathlib import Path
89from xml .parsers .expat import ExpatError
910
1011from pre_commit_hooks .util import (
@@ -37,6 +38,22 @@ def build_argument_parser():
3738 return parser
3839
3940
41+ def _check_case_sensitive_path (path ):
42+ # Return immediately if the file does not exist
43+ if not os .path .exists (path ):
44+ return False
45+
46+ p = Path (path )
47+ while True :
48+ # At root, p == p.parent --> break loop and return True
49+ if p == p .parent :
50+ return True
51+ # If string representation of path is not in parent directory, return False
52+ if str (p ) not in map (str , p .parent .iterdir ()):
53+ return False
54+ p = p .parent
55+
56+
4057def main (argv = None ):
4158 """Main process."""
4259
@@ -114,6 +131,22 @@ def main(argv=None):
114131 )
115132 retval = 1
116133
134+ # Check for missing installer items
135+ if all (
136+ (
137+ "installer_item_location" in pkginfo ,
138+ not _check_case_sensitive_path (
139+ os .path .join ("pkgs" , pkginfo .get ("installer_item_location" ))
140+ ),
141+ )
142+ ):
143+ print (
144+ "{}: installer item does not exist or path is not case sensitive" .format (
145+ filename
146+ )
147+ )
148+ retval = 1
149+
117150 # Check for pkg filenames showing signs of duplicate imports.
118151 if pkginfo .get ("installer_item_location" , "" ).endswith (tuple (dupe_suffixes )):
119152 print (
You can’t perform that action at this time.
0 commit comments