Skip to content

Commit f2de47f

Browse files
authored
Merge pull request #86 from haircut/main
feat: add `--warn-on-missing-installer-items` flag
2 parents 2d7f7c4 + 533bced commit f2de47f

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ After adding a hook to your pre-commit config, it's not a bad idea to run `pre-c
120120
- Choose to just warn if icons referenced in pkginfo files are missing (this will allow pre-commit checks to pass if no other issues exist):
121121
`args: ['--warn-on-missing-icons]`
122122

123+
- Choose to just warn if installer items (`installer_item_location`) referenced in pkginfo files are missing (this will allow pre-commit checks to pass if no other issues exist):
124+
`args: ['--warn-on-missing-installer-items]`
125+
123126
- Choose to just warn if pkg/pkginfo files with __1 (or similar) suffixes are detected (this will allow pre-commit checks to pass if no other issues exist):
124127
`args: ['--warn-on-duplicate-imports]`
125128

pre_commit_hooks/check_munki_pkgsinfo.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ def build_argument_parser():
4646
action="store_true",
4747
default=False,
4848
)
49+
parser.add_argument(
50+
"--warn-on-missing-installer-items",
51+
help="If added, this will only warn on missing installer items.",
52+
action="store_true",
53+
default=False,
54+
)
4955
parser.add_argument(
5056
"--warn-on-duplicate-imports",
5157
help="If added, this will only warn if pkginfo/pkg files end with a __1 suffix.",
@@ -144,10 +150,12 @@ def main(argv=None):
144150
args.munki_repo, "pkgs", pkginfo.get("installer_item_location", "")
145151
)
146152
):
147-
print(
148-
f"{filename}: installer item does not exist or path is not case sensitive"
149-
)
150-
retval = 1
153+
msg = "installer item does not exist or path is not case sensitive"
154+
if args.warn_on_missing_installer_items:
155+
print(f"{filename}: WARNING: {msg}")
156+
else:
157+
print(f"{filename}: {msg}")
158+
retval = 1
151159

152160
# Check for pkg filenames showing signs of duplicate imports.
153161
if pkginfo.get("installer_item_location", "").endswith(tuple(dupe_suffixes)):

0 commit comments

Comments
 (0)