Commit af386793e7
af386793e701976293c05fbdd409470cb324915a
parent: 47daf032cc
Unsigned
cmc <hello@cleberg.net> · 2025-01-25 02:26 UTC
add more git hooks
Layout: unified · split
utils/hooks/post-commit
+14 −2
| @@ -1,4 +1,16 @@ |
| 1 | 1 | # .git/hooks/post-commit |
| 2 | 2 | #!/bin/bash |
| 3 | | echo "Commit added:" |
| 4 | | git show --stat |
| 3 | echo "Environment: Development" |
| 4 | |
| 5 | # Remove previous build |
| 6 | rm -rf .build/* |
| 7 | |
| 8 | # Run publishing script |
| 9 | emacs --script publish.el |
| 10 | |
| 11 | # Minify CSS |
| 12 | minify -o theme/static/styles.min.css theme/static/styles.css |
| 13 | |
| 14 | # Launch development web server |
| 15 | cd .build/ |
| 16 | python3 -m http.server |
utils/hooks/post-push
added
+29
| @@ -0,0 +1,29 @@ |
| 1 | # .git/hooks/post-push |
| 2 | #!/bin/bash |
| 3 | echo "Environment: Production" |
| 4 | |
| 5 | # Check if publishing via LAN or remotely |
| 6 | printf "Publishing on remote or LAN? [r|l] " |
| 7 | |
| 8 | # Update ubuntu_server variable based on answer |
| 9 | read method |
| 10 | if [[ "$method" =~ ^[Rr]$ ]]; then |
| 11 | ubuntu_server="ubuntu-remote" |
| 12 | elif [[ "$method" =~ ^[Ll]$ ]]; then |
| 13 | ubuntu_server="ubuntu" |
| 14 | else |
| 15 | echo "Invalid input. Assuming LAN (ubuntu)" |
| 16 | ubuntu_server="ubuntu" |
| 17 | fi |
| 18 | |
| 19 | # Remove previous build |
| 20 | rm -rf .build/* |
| 21 | |
| 22 | # Run publishing script |
| 23 | emacs --script publish.el &>/dev/null |
| 24 | |
| 25 | # Minify CSS |
| 26 | minify -o theme/static/styles.min.css theme/static/styles.css |
| 27 | |
| 28 | # Deploy changes |
| 29 | rsync -r --delete-before .build/* $ubuntu_server:/var/www/cleberg.net/ |
utils/hooks/pre-commit
added
+8
| @@ -0,0 +1,8 @@ |
| 1 | # .git/hooks/pre-commit |
| 2 | #!/bin/bash |
| 3 | for file in $(git diff --cached --name-only | grep -E '\.org$'); do |
| 4 | if ! grep -q "^#\+TITLE:" "$file"; then |
| 5 | echo "Error: $file is missing a TITLE." |
| 6 | exit 1 |
| 7 | fi |
| 8 | done |