diff --git a/CHANGELOG.md b/CHANGELOG.md index 8782d2f..0efbf21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,13 @@ All notable changes to this project will be documented in this file. This projec Nothing yet. +## [1.14.0] - 2023-11-19 + +### Added + +- `check-preference-manifests` hook now outputs more specific error message if `pfm_documentation_url` is empty (#67, thanks to @relgit). +- `check-munki-pkgsinfo` hook now detects path mismatches on case-sensitive filesystems (#66, thanks to @AaronBurchfield). + ## [1.13.0] - 2023-11-18 ### Changed diff --git a/README.md b/README.md index 77a18ef..794d2b4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ For any hook in this repo you wish to use, add the following to your pre-commit ```yaml - repo: https://github.com/homebysix/pre-commit-macadmin - rev: v1.13.0 + rev: v1.14.0 hooks: - id: check-plists # - id: ... @@ -121,7 +121,7 @@ When combining arguments that take lists (for example: `--required-keys`, `--cat ```yaml - repo: https://github.com/homebysix/pre-commit-macadmin - rev: v1.13.0 + rev: v1.14.0 hooks: - id: check-munki-pkgsinfo args: ['--catalogs', 'testing', 'stable', '--'] @@ -131,7 +131,7 @@ But if you also use the `--categories` argument, you would move the trailing `-- ```yaml - repo: https://github.com/homebysix/pre-commit-macadmin - rev: v1.13.0 + rev: v1.14.0 hooks: - id: check-munki-pkgsinfo 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 ```yaml - repo: https://github.com/homebysix/pre-commit-macadmin - rev: v1.13.0 + rev: v1.14.0 hooks: - id: check-munki-pkgsinfo args: [ diff --git a/pre_commit_hooks/check_munki_pkgsinfo.py b/pre_commit_hooks/check_munki_pkgsinfo.py index 756bd27..26b7768 100755 --- a/pre_commit_hooks/check_munki_pkgsinfo.py +++ b/pre_commit_hooks/check_munki_pkgsinfo.py @@ -5,6 +5,7 @@ import argparse import os import plistlib +from pathlib import Path from xml.parsers.expat import ExpatError from pre_commit_hooks.util import ( @@ -37,6 +38,22 @@ def build_argument_parser(): return parser +def _check_case_sensitive_path(path): + # Return immediately if the file does not exist + if not os.path.exists(path): + return False + + p = Path(path) + while True: + # At root, p == p.parent --> break loop and return True + if p == p.parent: + return True + # If string representation of path is not in parent directory, return False + if str(p) not in map(str, p.parent.iterdir()): + return False + p = p.parent + + def main(argv=None): """Main process.""" @@ -114,6 +131,22 @@ def main(argv=None): ) retval = 1 + # Check for missing installer items + if all( + ( + "installer_item_location" in pkginfo, + not _check_case_sensitive_path( + os.path.join("pkgs", pkginfo.get("installer_item_location")) + ), + ) + ): + print( + "{}: installer item does not exist or path is not case sensitive".format( + filename + ) + ) + retval = 1 + # Check for pkg filenames showing signs of duplicate imports. if pkginfo.get("installer_item_location", "").endswith(tuple(dupe_suffixes)): print( diff --git a/pre_commit_hooks/check_preference_manifests.py b/pre_commit_hooks/check_preference_manifests.py index 08cb2e6..2538912 100755 --- a/pre_commit_hooks/check_preference_manifests.py +++ b/pre_commit_hooks/check_preference_manifests.py @@ -324,7 +324,15 @@ def validate_urls(subkey, filename): url_keys = ("pfm_app_url", "pfm_documentation_url") for url_key in url_keys: if url_key in subkey: - if not subkey[url_key].startswith("http"): + if len(subkey[url_key]) == 0: + print( + "{}: {} URL value is empty.".format( + filename, + url_key, + ) + ) + passed = False + elif not subkey[url_key].startswith("http"): print( "{}: {} value doesn't look like a URL: {}".format( filename, diff --git a/setup.py b/setup.py index b9a0768..e46c825 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ name="pre-commit-macadmin", description="Pre-commit hooks for Mac admins, client engineers, and IT consultants.", url="https://github.com/homebysix/pre-commit-macadmin", - version="1.13.0", + version="1.14.0", author="Elliot Jordan", author_email="elliot@elliotjordan.com", packages=["pre_commit_hooks"],