k7dxs-dns/.pre-commit

15 lines
450 B
Plaintext
Raw Normal View History

2023-09-14 03:44:15 +00:00
#!/bin/bash
set -e
function checkFile() {
[[ "$1" =~ \.zone$ ]] || return 0
2023-12-15 22:29:42 +00:00
[[ -f "$1" ]] || return 0 # allow deleting zone
2023-09-14 03:44:15 +00:00
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