From 5084aa54b1c401406be98499825289b7f12cf5c8 Mon Sep 17 00:00:00 2001 From: Dessa Simpson Date: Wed, 13 Sep 2023 20:44:15 -0700 Subject: [PATCH] add .pre-commit --- .pre-commit | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 .pre-commit diff --git a/.pre-commit b/.pre-commit new file mode 100755 index 0000000..4448673 --- /dev/null +++ b/.pre-commit @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +function checkFile() { + [[ "$1" =~ \.zone$ ]] || return 0 + old="$(git show HEAD:"$1"|grep -Po '\d+(?=\s+; serial)')" + new="$(git show :"$1"|grep -Po '\d+(?=\s+; serial)')" + [[ "$old" -lt "$new" ]] && return 0 || { echo "serial bump check failed for $1"; return 1; } +} + +ret=0 +while read file; do checkFile "$file" || ret=1; done <<< "$(git diff --name-only --cached)" +exit $ret