Add tracked Git hooks and refactor timeline arrows
- Add .githooks directory with pre-commit hook for cv.webp generation - Create installation script for hooks setup - Add documentation for hooks usage - Refactor timeline arrows into reusable commands (\timelinearrow and \timelinearrowcontinue) - Simplify arrow usage by only requiring length parameter
This commit is contained in:
46
.githooks/pre-commit
Executable file
46
.githooks/pre-commit
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Pre-commit hook to generate cv.webp from cv.pdf
|
||||
|
||||
# Check if cv.pdf exists and is staged
|
||||
if git diff --cached --name-only | grep -q "^cv\.pdf$"; then
|
||||
echo "cv.pdf is being committed, generating cv.webp..."
|
||||
|
||||
# Generate webp from first page of PDF
|
||||
if [ -f "cv.pdf" ]; then
|
||||
# Use pdftoppm to convert first page to PNG, then ImageMagick to convert to WebP
|
||||
pdftoppm -png -f 1 -l 1 -singlefile cv.pdf temp_cv && \
|
||||
magick temp_cv.png -quality 85 img/cv.webp && \
|
||||
rm -f temp_cv.png
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully generated img/cv.webp"
|
||||
# Add the generated image to the commit
|
||||
git add img/cv.webp
|
||||
else
|
||||
echo "Warning: Failed to generate cv.webp"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Warning: cv.pdf not found, skipping cv.webp generation"
|
||||
fi
|
||||
elif [ -f "cv.pdf" ]; then
|
||||
# cv.pdf exists but is not being committed, check if it's newer than cv.webp
|
||||
if [ ! -f "img/cv.webp" ] || [ "cv.pdf" -nt "img/cv.webp" ]; then
|
||||
echo "cv.pdf has been modified but not staged. Generating cv.webp anyway..."
|
||||
|
||||
pdftoppm -png -f 1 -l 1 -singlefile cv.pdf temp_cv && \
|
||||
magick temp_cv.png -quality 85 img/cv.webp && \
|
||||
rm -f temp_cv.png
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully generated img/cv.webp"
|
||||
git add img/cv.webp
|
||||
else
|
||||
echo "Warning: Failed to generate cv.webp"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user