Skip to content

Commit 5321b03

Browse files
committed
Add hook to check image names
1 parent 7859a48 commit 5321b03

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.pre-commit-config.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ repos:
2020
rev: 'v8.0.1'
2121
hooks:
2222
- id: clang-format
23+
- repo: local
24+
hooks:
25+
- id: check-image-naming
26+
name: check image names
27+
language: python
28+
entry: tools/check-image-names.py
29+
files: ".*/images/.*"

tools/check-image-names.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!python3
2+
3+
import sys
4+
import os
5+
6+
problems = False
7+
for file in sys.argv[1:]:
8+
parts = file.split(os.sep)
9+
# Ignore non-interesting files
10+
if len(parts) != 3 or parts[1] != "images":
11+
continue
12+
13+
if parts[0] == "quickstart":
14+
prefix = "quickstart-"
15+
else:
16+
prefix = f"tutorials-{parts[0]}-"
17+
18+
if not parts[2].startswith(prefix):
19+
print(f"Incorrect: {file}")
20+
print(f"Expected prefix: {prefix}")
21+
print()
22+
problems = True
23+
24+
sys.exit(1 if problems else 0)

0 commit comments

Comments
 (0)