git: 414b5c616456 - main - .hooks/pre-commit.d: unbreak EPOCH checker
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 18 Dec 2022 08:59:22 UTC
The branch main has been updated by tcberner: URL: https://cgit.FreeBSD.org/ports/commit/?id=414b5c61645669a346fc817e0b5852c265b96187 commit 414b5c61645669a346fc817e0b5852c265b96187 Author: Matthias Andree <mandree@FreeBSD.org> AuthorDate: 2022-11-27 12:51:51 +0000 Commit: Tobias C. Berner <tcberner@FreeBSD.org> CommitDate: 2022-12-18 08:58:17 +0000 .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 --- .hooks/pre-commit.d/check_portepoch | 6 +++--- 1 file 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