git: e0dd1e987a5e - main - .hooks/pre-commit.d: unbreak EPOCH checker
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 16 Dec 2022 22:52:40 UTC
The branch main has been updated by mandree: URL: https://cgit.FreeBSD.org/ports/commit/?id=e0dd1e987a5eaa27cf7b46043db663ff51b1cdc2 commit e0dd1e987a5eaa27cf7b46043db663ff51b1cdc2 Author: Matthias Andree <mandree@FreeBSD.org> AuthorDate: 2022-11-27 12:51:51 +0000 Commit: Matthias Andree <mandree@FreeBSD.org> CommitDate: 2022-12-16 22:08:29 +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. --- .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