Skip to content

Commit beedf3f

Browse files
committed
Check naming convention of MunkiAdmin scripts
1 parent 5c890c7 commit beedf3f

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

.pre-commit-hooks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
- id: check-munkiadmin-scripts
7373
name: Check MunkiAdmin Scripts
74-
description: This hook ensures MunkiAdmin scripts are executable.
74+
description: This hook ensures MunkiAdmin scripts are named properly and executable.
7575
entry: check-munkiadmin-scripts
7676
language: python
7777
files: "^MunkiAdmin/scripts/"

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file. This projec
1515
### Added
1616

1717
- `check-munki-pkgsinfo` now produces an error if `uninstall_method` is set to `uninstall_script` but no uninstall script is present in the pkginfo.
18+
- `check-munkiadmin-scripts` now checks whether scripts are named correctly, not just executable.
1819

1920
## [1.17.0] - 2024-12-22
2021

pre_commit_hooks/check_munkiadmin_scripts.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ def main(argv=None):
2727
retval = 0
2828
for filename in args.filenames:
2929

30+
# Ensure scripts are named properly.
31+
# https://github.com/hjuutilainen/munkiadmin/blob/4f4e96da1f1c7a4dfe7da59d88f1ef68ee02b8f2/MunkiAdmin/Singletons/MAMunkiRepositoryManager.m#L23
32+
prefixes = ["manifest", "pkginfo", "repository"]
33+
actions = ["custom", "postopen", "postsave", "presave"]
34+
ma_script_prefixes = [f"{p}-{a}" for p in prefixes for a in actions]
35+
if not any(filename.startswith(prefix) for prefix in ma_script_prefixes):
36+
print(f"{filename}: does not start with a valid MunkiAdmin script prefix")
37+
retval = 1
38+
3039
# Ensure scripts are executable
3140
if not os.access(filename, os.X_OK):
3241
print(f"{filename}: not executable")

0 commit comments

Comments
 (0)