summaryrefslogtreecommitdiff
path: root/.hooks
diff options
context:
space:
mode:
authorMatthias Andree <mandree@FreeBSD.org>2022-11-27 13:51:51 +0100
committerTobias C. Berner <tcberner@FreeBSD.org>2022-12-18 09:58:17 +0100
commit414b5c61645669a346fc817e0b5852c265b96187 (patch)
treecad80226258ad9b8b9a3d4d36ebf3be7813e2439 /.hooks
parentsecurity/klee: Switch to USES=llvm. (diff)
.hooks/pre-commit.d: unbreak EPOCH checker
dns/dnsmasq-devel as of 2.88rc3 contained a comment about PORTEPOCH, which I removed in the 2.88rc5. This tripped up the checker because it assumed that if git yielded lines containing PORTEPOCH, then it must have been PORTEPOCH= or similar lines. Untrue in my case. It was printing [pre-commit] dropped PORTEPOCH in dns/dnsmasq-devel/Makefile To solve, only pick out PORTEPOCH diffs that are actual assignments, and if the new PORTEPOCH is empty, and the old one is also, ignore this condition (previously we would exit 1, which is bogus). Also, grep without -E should not have \ in front of - or +. FreeBSD 13.1 grep is fine, but GNU grep ignores those backslashes noisily (and I have prepended it to PATH) and emits warnings. PR: 268024
Diffstat (limited to '.hooks')
-rwxr-xr-x.hooks/pre-commit.d/check_portepoch6
1 files changed, 3 insertions, 3 deletions
diff --git a/.hooks/pre-commit.d/check_portepoch b/.hooks/pre-commit.d/check_portepoch
index 1a59a39b5407..34d93e2efcf4 100755
--- a/.hooks/pre-commit.d/check_portepoch
+++ b/.hooks/pre-commit.d/check_portepoch
@@ -5,9 +5,9 @@
check_epoch() {
local makefile="$1"
- local old_epoch=$(git diff --cached -U0 "${makefile}" | grep '^\-PORTEPOCH' | grep -oE '[0-9]+')
- local new_epoch=$(git diff --cached -U0 "${makefile}" | grep '^\+PORTEPOCH' | grep -oE '[0-9]+')
- if [ -z "${new_epoch}" ] ; then
+ local old_epoch=$(git diff --cached -U0 "${makefile}" | grep '^-PORTEPOCH.*=' | grep -oE '[0-9]+')
+ local new_epoch=$(git diff --cached -U0 "${makefile}" | grep '^+PORTEPOCH.*=' | grep -oE '[0-9]+')
+ if [ -z "${new_epoch}" -a -n "${old_epoch}" ] ; then
echo "[pre-commit] dropped PORTEPOCH ${old_epoch} in ${makefile}"
exit 1
fi