Skip to content

Commit 2ad7bf8

Browse files
authored
Merge pull request #69 from homebysix/1.13.0
1.13.0 merge to main
2 parents 624a708 + fc4dc82 commit 2ad7bf8

6 files changed

Lines changed: 26 additions & 19 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.5.0
44
hooks:
55
- id: check-ast
66
- id: check-byte-order-marker
@@ -17,6 +17,6 @@ repos:
1717
- id: trailing-whitespace
1818
args: [--markdown-linebreak-ext=md]
1919
- repo: https://github.com/python/black
20-
rev: 22.12.0
20+
rev: 23.11.0
2121
hooks:
2222
- id: black

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ All notable changes to this project will be documented in this file. This projec
1414

1515
Nothing yet.
1616

17+
## [1.13.0] - 2023-11-18
18+
19+
### Changed
20+
21+
- Now uses `packaging.version.Version` instead of `distutils.version.LooseVersion` for AutoPkg version comparisons. This may cause unexpected behavior if unusual versions are used in `MinimumVersion` keys.
22+
- Updated `yaml.safe_load()` to `YAML(typ='safe')`.
23+
1724
## [1.12.4] - 2023-02-26
1825

1926
### Added
@@ -304,7 +311,8 @@ Nothing yet.
304311

305312
- Initial release
306313

307-
[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.12.4...HEAD
314+
[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.13.0...HEAD
315+
[1.13.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.12.4...v1.13.0
308316
[1.12.4]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.12.3...v1.12.4
309317
[1.12.3]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.12.2...v1.12.3
310318
[1.12.2]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.12.1...v1.12.2

README.md

Lines changed: 4 additions & 4 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.12.4
18+
rev: v1.13.0
1919
hooks:
2020
- id: check-plists
2121
# - id: ...
@@ -121,7 +121,7 @@ When combining arguments that take lists (for example: `--required-keys`, `--cat
121121

122122
```yaml
123123
- repo: https://github.com/homebysix/pre-commit-macadmin
124-
rev: v1.12.4
124+
rev: v1.13.0
125125
hooks:
126126
- id: check-munki-pkgsinfo
127127
args: ['--catalogs', 'testing', 'stable', '--']
@@ -131,7 +131,7 @@ But if you also use the `--categories` argument, you would move the trailing `--
131131

132132
```yaml
133133
- repo: https://github.com/homebysix/pre-commit-macadmin
134-
rev: v1.12.4
134+
rev: v1.13.0
135135
hooks:
136136
- id: check-munki-pkgsinfo
137137
args: ['--catalogs', 'testing', 'stable', '--categories', 'Design', 'Engineering', 'Web Browsers', '--']
@@ -143,7 +143,7 @@ If it looks better to your eye, feel free to use a multi-line list for long argu
143143

144144
```yaml
145145
- repo: https://github.com/homebysix/pre-commit-macadmin
146-
rev: v1.12.4
146+
rev: v1.13.0
147147
hooks:
148148
- id: check-munki-pkgsinfo
149149
args: [

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
import sys
99
from contextlib import contextmanager
10-
from distutils.version import LooseVersion
10+
from packaging.version import Version
1111

1212
from pre_commit_hooks.util import (
1313
load_autopkg_recipe,
@@ -179,17 +179,15 @@ def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename)
179179
# Warn if using a MinimumVersion greater than or equal to 2
180180
# warn_on_vers = "2"
181181
# suggest_vers = "1.4.1"
182-
# if LooseVersion(min_vers) >= LooseVersion(warn_on_vers):
182+
# if Version(min_vers) >= Version(warn_on_vers):
183183
# print(
184184
# "{}: WARNING: Choosing MinimumVersion {} limits the potential "
185185
# "audience for your AutoPkg recipe. Consider using MinimumVersion "
186186
# "{} if your processors support it.".format(filename, min_vers, suggest_vers)
187187
# )
188188

189189
# Processors for which a minimum version of AutoPkg is required.
190-
# Note: Because LooseVersion considers version 1.0 to be "less than" 1.0.0,
191-
# specifying more trailing zeros than needed in the dict below may result
192-
# in false positive errors for users of the check-autopkg-recipes hook.
190+
# Note: packaging.version.Version considers this True: "1.0" == "1.0.0"
193191
proc_min_versions = {
194192
"AppPkgCreator": "1.0",
195193
"BrewCaskInfoProvider": "0.2.5",
@@ -230,10 +228,10 @@ def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename)
230228
for proc in [
231229
x
232230
for x in proc_min_versions
233-
if LooseVersion(proc_min_versions[x]) >= LooseVersion(ignore_min_vers_before)
231+
if Version(proc_min_versions[x]) >= Version(ignore_min_vers_before)
234232
]:
235233
if proc in [x.get("Processor") for x in process]:
236-
if LooseVersion(min_vers) < LooseVersion(proc_min_versions[proc]):
234+
if Version(min_vers) < Version(proc_min_versions[proc]):
237235
print(
238236
"{}: {} processor requires minimum AutoPkg "
239237
"version {}".format(filename, proc, proc_min_versions[proc])
@@ -544,7 +542,6 @@ def main(argv=None):
544542

545543
retval = 0
546544
for filename in args.filenames:
547-
548545
recipe = load_autopkg_recipe(filename)
549546
if not recipe:
550547
retval = 1

pre_commit_hooks/util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
import sys
77
from datetime import datetime
88

9-
from ruamel import yaml
9+
import ruamel.yaml
10+
11+
yaml = ruamel.yaml.YAML(typ="safe")
1012

1113
# Plist data types and their Python equivalents
1214
PLIST_TYPES = {
@@ -31,7 +33,7 @@ def load_autopkg_recipe(path):
3133
try:
3234
# try to read it as yaml
3335
with open(path, "rb") as f:
34-
recipe = yaml.safe_load(f)
36+
recipe = yaml.load(f)
3537
except Exception as err:
3638
print("{}: yaml parsing error: {}".format(path, err))
3739
elif path.endswith(".json"):

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
name="pre-commit-macadmin",
88
description="Pre-commit hooks for Mac admins, client engineers, and IT consultants.",
99
url="https://github.com/homebysix/pre-commit-macadmin",
10-
version="1.12.4",
10+
version="1.13.0",
1111
author="Elliot Jordan",
1212
author_email="elliot@elliotjordan.com",
1313
packages=["pre_commit_hooks"],
14-
install_requires=["ruamel.yaml>=0.15"],
14+
install_requires=["ruamel.yaml>=0.15", "packaging>=23.2"],
1515
entry_points={
1616
"console_scripts": [
1717
"check-autopkg-recipe-list = pre_commit_hooks.check_autopkg_recipe_list:main",

0 commit comments

Comments
 (0)