From 1762c6f54d5b61420a173d28162ffefc11a365ab Mon Sep 17 00:00:00 2001 From: Mackenzie Davidson Date: Thu, 18 Dec 2025 15:16:04 -0500 Subject: [PATCH] update git pre-commit hook --- readme.md | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/readme.md b/readme.md index cdbe2cd..2f3e5b9 100644 --- a/readme.md +++ b/readme.md @@ -45,35 +45,28 @@ git clone --depth=1 --no-checkout https://github.com/mwvd/css.git _tmp_css && \ ``` #!/usr/bin/env bash -# runs build-min and stages any resulting changes to min.css - -# ./git/hooks/pre-commit - -# make sure this hook and build-min are both executable: -# -# chmod +x ./git/hooks/pre-commit -# chmod +x ./build-min - set -e set -u set -o pipefail -# check if min.css was modified before running build-min -git diff --quiet min.css -before_build=$? +# check if reset.css is staged +if ! git diff --quiet --cached style/base/reset.css; then + # if reset.css is staged, check that min.css is staged too + if git diff --quiet --cached min.css; then + echo " +it looks like you edited styles/base/reset.css +but didn't update min.css with your changes + +to rebuild min.css with your changes, you can run: +$ ./build-min -# run the build-min -./build-min +and then add and commit your changes -# check if min.css was modified by build-min -git diff --quiet min.css -after_build=$? +(to bypass this check, run git commit again with --no-verify)" -# if min.css was modified by build-min, then add it to our commit -if [ $before_build -eq 0 ] && [ $after_build -ne 0 ]; then - git add min.css - echo "staged updated min.css, adding updated min.css to commit" + # exit with error + exit 1 + fi fi -exit 0 ``` -- knotmirror 0.0.1