Skip to content

Commit 4a985a6

Browse files
committed
Merge remote-tracking branch 'origin/1.17.0' into dev
2 parents 90f7e8d + b2799bb commit 4a985a6

File tree

4 files changed

+38
-19
lines changed

4 files changed

+38
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ All notable changes to this project will be documented in this file. This projec
1212

1313
## [Unreleased]
1414

15-
Nothing yet.
15+
### Added
16+
17+
- New `--warn-on-duplicate-imports` flag for use with Munki pkginfo checks, for Munki administrators who don't care about multiple potential versions of the same pkginfo/pkg in the repository (perhaps because of differing `supported_architectures` or other keys).
18+
19+
When this is specified, the pre-commit hook will warn when files with `__1` (and similar) suffixes are seen in the pkgsinfo/pkgs folders. This will enbale pre-commit hooks to pass, as long as there are no other errors. Omitting the `--warn-on-duplicate-imports` flag will continue generating an error and failing the hooks, as was the previous behavior.
1620

1721
## [1.16.2] - 2024-06-10
1822

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ For any hook in this repo you wish to use, add the following to your pre-commit
1515

1616
```yaml
1717
- repo: https://github.com/homebysix/pre-commit-macadmin
18-
rev: v1.16.2
18+
rev: v1.17.0
1919
hooks:
2020
- id: check-plists
2121
# - id: ...
@@ -61,18 +61,18 @@ After adding a hook to your pre-commit config, it's not a bad idea to run `pre-c
6161
This hook checks AutoPkg recipes to ensure they meet various requirements and conventions.
6262

6363
- Optionally specify your preferred AutoPkg recipe and/or override prefix, if you wish to enforce them:
64-
`args: ['--override-prefix=com.yourcompany.autopkg.']`
65-
(default: `local.`)
66-
`args: ['--recipe-prefix=com.github.yourusername.']`
64+
`args: ['--override-prefix=com.yourcompany.autopkg.']`
65+
(default: `local.`)
66+
`args: ['--recipe-prefix=com.github.yourusername.']`
6767
(default: `com.github.`)
6868

6969
- Optionally specify the version of AutoPkg for which you want to ignore MinimumVersion mismatches with processors.
70-
`args: ['--ignore-min-vers-before=0.5.0']`
71-
(default: `1.0.0`)
70+
`args: ['--ignore-min-vers-before=0.5.0']`
71+
(default: `1.0.0`)
7272
Specifying `0.1.0` will not ignore any MinimumVersion mismatches.
7373

74-
- If you're a purist, you can also enable strict mode. This enforces recipe type conventions, all processor/MinimumVersion mismatches, forbids `<!-- -->` style comments, and ensures all processor input variables (arguments) are valid.
75-
`args: ['--strict']`
74+
- If you're a purist, you can also enable strict mode. This enforces recipe type conventions, all processor/MinimumVersion mismatches, forbids `<!-- -->` style comments, and ensures all processor input variables (arguments) are valid.
75+
`args: ['--strict']`
7676
(default: False)
7777

7878
- __forbid-autopkg-overrides__
@@ -117,9 +117,12 @@ After adding a hook to your pre-commit config, it's not a bad idea to run `pre-c
117117
`args: ['--munki-repo', './my_repo_location']`
118118
(default: ".")
119119

120-
- Choose to just warn on missing icons with a flag, note if no other issues exist this will allow pre-commit to pass without seeing the warnings:
120+
- 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 pkg/pkginfo files with __1 (or similar) suffixes are detected (this will allow pre-commit checks to pass if no other issues exist):
124+
`args: ['--warn-on-duplicate-imports]`
125+
123126
- Add additional shebangs that are valid for your environment:
124127
`args: ['--valid-shebangs', '#!/bin/macadmin/python37', '#!/bin/macadmin/python42', '--']`
125128

@@ -141,7 +144,7 @@ When combining arguments that take lists (for example: `--required-keys`, `--cat
141144

142145
```yaml
143146
- repo: https://github.com/homebysix/pre-commit-macadmin
144-
rev: v1.16.2
147+
rev: v1.17.0
145148
hooks:
146149
- id: check-munki-pkgsinfo
147150
args: ['--catalogs', 'testing', 'stable', '--']
@@ -151,7 +154,7 @@ But if you also use the `--categories` argument, you would move the trailing `--
151154

152155
```yaml
153156
- repo: https://github.com/homebysix/pre-commit-macadmin
154-
rev: v1.16.2
157+
rev: v1.17.0
155158
hooks:
156159
- id: check-munki-pkgsinfo
157160
args: ['--catalogs', 'testing', 'stable', '--categories', 'Design', 'Engineering', 'Web Browsers', '--']
@@ -163,7 +166,7 @@ If it looks better to your eye, feel free to use a multi-line list for long argu
163166

164167
```yaml
165168
- repo: https://github.com/homebysix/pre-commit-macadmin
166-
rev: v1.16.2
169+
rev: v1.17.0
167170
hooks:
168171
- id: check-munki-pkgsinfo
169172
args: [

pre_commit_hooks/check_munki_pkgsinfo.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ def build_argument_parser():
4545
action="store_true",
4646
default=False,
4747
)
48+
parser.add_argument(
49+
"--warn-on-duplicate-imports",
50+
help="If added, this will only warn if pkginfo/pkg files end with a __1 suffix.",
51+
action="store_true",
52+
default=False,
53+
)
4854
parser.add_argument(
4955
"--valid-shebangs",
5056
nargs="+",
@@ -154,10 +160,15 @@ def main(argv=None):
154160

155161
# Check for pkg filenames showing signs of duplicate imports.
156162
if pkginfo.get("installer_item_location", "").endswith(tuple(dupe_suffixes)):
157-
print(
158-
f'{filename}: installer item "{pkginfo.get("installer_item_location")}" may be a duplicate import'
163+
installer_item_location = pkginfo["installer_item_location"]
164+
msg = (
165+
f"installer item '{installer_item_location}' may be a duplicate import"
159166
)
160-
retval = 1
167+
if args.warn_on_missing_icons:
168+
print(f"{filename}: WARNING: {msg}")
169+
else:
170+
print(f"{filename}: {msg}")
171+
retval = 1
161172

162173
# Checking for the absence of blocking_applications for pkg installers.
163174
# If a pkg doesn't require blocking_applications, use empty "<array/>" in pkginfo.
@@ -184,10 +195,11 @@ def main(argv=None):
184195
pkginfo.get("installer_type") == "apple_update_metadata",
185196
)
186197
):
198+
msg = f"missing icon"
187199
if args.warn_on_missing_icons:
188-
print(f"WARNING: {filename}: missing icon")
200+
print(f"{filename}: WARNING: {msg}")
189201
else:
190-
print(f"{filename}: missing icon")
202+
print(f"{filename}: {msg}")
191203
retval = 1
192204

193205
# Ensure uninstall method is set correctly if uninstall_script exists.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
name="pre-commit-macadmin",
77
description="Pre-commit hooks for Mac admins, client engineers, and IT consultants.",
88
url="https://github.com/homebysix/pre-commit-macadmin",
9-
version="1.16.2",
9+
version="1.17.0",
1010
author="Elliot Jordan",
1111
author_email="[email protected]",
1212
packages=["pre_commit_hooks"],

0 commit comments

Comments
 (0)