[Bug 268024] .hooks/pre-commit.d/check_portepoch broken on lines affecting PORTEPOCH comments

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 27 Nov 2022 22:53:34 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268024

            Bug ID: 268024
           Summary: .hooks/pre-commit.d/check_portepoch broken on lines
                    affecting PORTEPOCH comments
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Keywords: patch, regression
          Severity: Affects Many People
          Priority: ---
         Component: Ports Framework
          Assignee: portmgr@FreeBSD.org
          Reporter: mandree@FreeBSD.org
                CC: portmgr@FreeBSD.org, ports-bugs@FreeBSD.org
 Attachment #238381 maintainer-approval?(portmgr@FreeBSD.org)
             Flags:
                CC: portmgr@FreeBSD.org

Created attachment 238381
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=238381&action=edit
fix proposal for check_portepoch to fix various issues with it

I was editing dns/dnsmasq-devel 2.88rc3, to upgrade to rc5, and removed a
PORTEPOCH comment. This tripped up check_portepoch, which cannot cope with a
situation that git renders PORTEPOCH diffs that do not relate to ^PORTEPOCH=23
lines, and it printed 

[pre-commit] dropped PORTEPOCH  in dns/dnsmasq-devel/Makefile

So, because I was editing PORTEPOCH comments, git was emitting the lines, but
grep was not picking them up. Right. And then the first check for the exit 1
path was simplistic and just assumed "no new portepoch, we're broken". Untrue.


To fix, only complain about an empty PORTEPOCH if we had one before. If both
old and new are empty, we may be safe, so do not complain and do not error out.

Also note that GNU grep complains about the regexps, because it runs without -E
option, but the basic regex has \- (you never escape -) and \+ (which has
reverse meaning, and you do not want to match multiple ^ anchors instead of
matching the literal +), so fix that, too, and be stricter to only look at
^PORTEPOCH lines that have a = somewhere.

-- 
You are receiving this mail because:
You are on the CC list for the bug.