.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
This commit is contained in:
parent
08807ad950
commit
414b5c6164
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user