File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ import sys
3+ import pathlib
4+
5+ ROOT = pathlib .Path (__file__ ).resolve ().parent .parent .parent
6+ CONFIG_FILE = ROOT / ".pre-commit-config.yaml"
7+
8+
9+ def main (argv : list [str ]) -> int :
10+ if not CONFIG_FILE .exists ():
11+ print (".pre-commit-config.yaml not found in repo root" )
12+ return 1
13+
14+ config_text = CONFIG_FILE .read_text ()
15+
16+ missing = []
17+ for file_arg in argv :
18+ path = pathlib .Path (file_arg )
19+
20+ # only care about JSONs in repo root
21+ if path .suffix == ".json" and path .parent .resolve () == ROOT :
22+ print (f"Checking { path .name } ..." , flush = True )
23+ if path .name not in config_text :
24+ missing .append (path .name )
25+
26+ if missing :
27+ print ("\n These JSON files are missing from .pre-commit-config.yaml:" )
28+ for m in missing :
29+ print (f" - { m } " )
30+ return 1
31+
32+ return 0
33+
34+
35+ if __name__ == "__main__" :
36+ sys .exit (main (sys .argv [1 :]))
Original file line number Diff line number Diff line change 33# See https://pre-commit.com/hooks.html for more hooks
44
55repos :
6+ - repo : local
7+ hooks :
8+ - id : check-json-in-config
9+ name : Check Renovate presets are listed in pre-commit-config.yaml
10+ entry : .cicd/hooks/check-json-in-config.py
11+ language : python
12+ types : [json]
613 - repo : https://github.com/pre-commit/pre-commit-hooks
714 rev : v6.0.0
815 hooks :
3138 (^|/).?renovate(?:rc)?(?:\.json5?)?$|
3239 default.json|
3340 copier.json|
41+ groupManager.json|
3442 pre-commit.json|
3543 monthly.json|
3644 weekly.json|
You can’t perform that action at this time.
0 commit comments