1
0
forked from 0ad/0ad

Add pre-commit hook for filenames

Closes: #6327
This commit is contained in:
Ralph Sennhauser 2024-09-11 19:15:07 +02:00
parent fbe56136dd
commit 5b4484e401
2 changed files with 23 additions and 0 deletions

View File

@ -75,3 +75,10 @@ repos:
args:
- --strict
exclude: ^build/premake/premake5/
- repo: local
hooks:
- id: sane-filenames
name: sane-filenames
language: python
types: [file]
entry: ./lint/pre-commit-hooks/sane_filenames.py

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
import re
import sys
re_allowed_name = re.compile("^[-_./A-Za-z0-9]*$")
has_error = False
for f in sys.argv[1:]:
if not re_allowed_name.match(f):
has_error = True
print(f)
if has_error:
sys.exit(1)