the home site for me: also iteration 3 or 4 of my site
at main 1.5 kB view raw
1#!/usr/bin/env bash 2 3# Check if exiftool is installed 4if ! command -v exiftool &> /dev/null; then 5 echo "Error: exiftool is not installed. Please install it." >&2 6 exit 1 7fi 8 9# Flag to track if we found any draft files 10found_draft=0 11 12# First pass: check for draft files 13while 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 31done < <(git diff --cached --name-only --diff-filter=ACMR) 32 33# Exit if we found any draft files 34if [ $found_draft -eq 1 ]; then 35 exit 1 36fi 37 38# Second pass: process images 39while read -r file; do 40 case "$file" in 41 *.jpg|*.jpeg|*.png|*.gif|*.tiff|*.bmp) 42 # Store output of exiftool command 43 cleared_data=$(exiftool -all= --icc_profile:all -tagsfromfile @ -orientation -overwrite_original "$file") 44 if [ $? -ne 0 ]; then 45 echo "Error: exiftool failed to process $file" >&2 46 exit 1 47 fi 48 echo "Cleared EXIF data for $file:" >&2 49 echo "$cleared_data" >&2 50 git add "$file" 51 ;; 52 *) 53 ;; 54 esac 55done < <(git diff --cached --name-only --diff-filter=ACMR) 56 57exit 0