+31
-1
hooks/pre-commit
+31
-1
hooks/pre-commit
···
2
2
3
3
# Check if exiftool is installed
4
4
if ! command -v exiftool &> /dev/null; then
5
-
echo "Error: exiftool is not installed. Please install it." >&2
5
+
echo "Error: exiftool is not installed. Please install it." >&2
6
6
exit 1
7
7
fi
8
8
9
+
# Flag to track if we found any draft files
10
+
found_draft=0
11
+
12
+
# First pass: check for draft files
13
+
while read -r file; do
14
+
case "$file" in
15
+
*.md)
16
+
# Check if file contains draft = true within +++ header section
17
+
awk '
18
+
/^\+\+\+$/ { inblock = !inblock }
19
+
inblock && /draft = true/ { found = 1 }
20
+
END { exit(found ? 0 : 1) }
21
+
' "$file"
22
+
if [ $? -eq 0 ]; then
23
+
echo "Error: Draft file detected: $file" >&2
24
+
echo "Please remove draft status or unstage this file before committing." >&2
25
+
found_draft=1
26
+
fi
27
+
;;
28
+
*)
29
+
;;
30
+
esac
31
+
done < <(git diff --cached --name-only --diff-filter=ACMR)
32
+
33
+
# Exit if we found any draft files
34
+
if [ $found_draft -eq 1 ]; then
35
+
exit 1
36
+
fi
37
+
38
+
# Second pass: process images
9
39
while read -r file; do
10
40
case "$file" in
11
41
*.jpg|*.jpeg|*.png|*.gif|*.tiff|*.bmp)