pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint pkgtools/pkglint: update to 20.4.1



details:   https://anonhg.NetBSD.org/pkgsrc/rev/aad91c680264
branches:  trunk
changeset: 449095:aad91c680264
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Mar 20 23:32:43 2021 +0000

description:
pkgtools/pkglint: update to 20.4.1

Changes since 20.4.0:

When a package has MAINTAINER set and there are modified local files,
only remind the user once per package that changes should likely be
approved by the maintainer.  Previously there was a reminder once per
file, which was just too much for a package that has Makefile and PLIST
and maybe some patches changed.

Small performance improvement for loading the doc/CHANGES files, since
that costs a few tenths of seconds at every startup.

diffstat:

 pkgtools/pkglint/Makefile                    |   5 +-
 pkgtools/pkglint/files/mklines.go            |   2 +
 pkgtools/pkglint/files/package.go            |   2 +-
 pkgtools/pkglint/files/package_test.go       |  28 +++++++++++++-
 pkgtools/pkglint/files/pkgsrc.go             |  40 +++++++++++++++++++--
 pkgtools/pkglint/files/varalignblock_test.go |  51 ++++++++++++++++++++++++++++
 6 files changed, 117 insertions(+), 11 deletions(-)

diffs (219 lines):

diff -r a1184764d52a -r aad91c680264 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Mar 20 22:31:39 2021 +0000
+++ b/pkgtools/pkglint/Makefile Sat Mar 20 23:32:43 2021 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.679 2021/03/19 17:37:04 bsiegert Exp $
+# $NetBSD: Makefile,v 1.680 2021/03/20 23:32:43 rillig Exp $
 
-PKGNAME=       pkglint-20.4.0
-PKGREVISION=   3
+PKGNAME=       pkglint-20.4.1
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r a1184764d52a -r aad91c680264 pkgtools/pkglint/files/mklines.go
--- a/pkgtools/pkglint/files/mklines.go Sat Mar 20 22:31:39 2021 +0000
+++ b/pkgtools/pkglint/files/mklines.go Sat Mar 20 23:32:43 2021 +0000
@@ -40,6 +40,8 @@
        checkAllData mklinesCheckAll
 }
 
+// mklinesCheckAll contains the data that may only be accessed during a call
+// to MkLines.checkAll.
 type mklinesCheckAll struct {
        // Current make(1) target
        target string
diff -r a1184764d52a -r aad91c680264 pkgtools/pkglint/files/package.go
--- a/pkgtools/pkglint/files/package.go Sat Mar 20 22:31:39 2021 +0000
+++ b/pkgtools/pkglint/files/package.go Sat Mar 20 23:32:43 2021 +0000
@@ -1473,7 +1473,7 @@
                return
        }
 
-       line := NewLineWhole(filename)
+       line := NewLineWhole(pkg.File("."))
        line.Notef("Please only commit changes that %s would approve.", maintainer)
        line.Explain(
                "See the pkgsrc guide, section \"Package components\",",
diff -r a1184764d52a -r aad91c680264 pkgtools/pkglint/files/package_test.go
--- a/pkgtools/pkglint/files/package_test.go    Sat Mar 20 22:31:39 2021 +0000
+++ b/pkgtools/pkglint/files/package_test.go    Sat Mar 20 23:32:43 2021 +0000
@@ -3190,10 +3190,32 @@
        G.Check(t.File("category/package"))
 
        t.CheckOutputLines(
-               "NOTE: ~/category/package/Makefile: " +
+               "NOTE: ~/category/package: " +
                        "Please only commit changes that maintainer%example.org@localhost would approve.")
 }
 
+func (s *Suite) Test_Package_checkOwnerMaintainer__maintainer_unequal_several_files(c *check.C) {
+       t := s.Init(c)
+
+       G.Username = "example-user"
+       t.CreateFileLines("category/package/CVS/Entries",
+               "/Makefile//modified//",
+               "/PLIST//modified//",
+               "/distinfo//modified//")
+       t.SetUpPackage("category/package",
+               "MAINTAINER=\tmaintainer%example.org@localhost")
+       t.Chdir("category/package")
+       t.FinishSetUp()
+       G.Logger.verbose = false // Suppress duplicate messages
+
+       G.Check(".")
+
+       // TODO: Remove the ".:", it is more confusing than helpful.
+       t.CheckOutputLines(
+               "NOTE: .: Please only commit changes " +
+                       "that maintainer%example.org@localhost would approve.")
+}
+
 // A package with an OWNER may be edited by the owner itself.
 func (s *Suite) Test_Package_checkOwnerMaintainer__owner_equal(c *check.C) {
        t := s.Init(c)
@@ -3262,7 +3284,7 @@
        G.Check(pkg)
 
        t.CheckOutputLines(
-               "NOTE: ~/category/package/Makefile: Please only commit changes " +
+               "NOTE: ~/category/package: Please only commit changes " +
                        "that maintainer%example.org@localhost would approve.")
 }
 
@@ -3287,7 +3309,7 @@
 
        // No warning for the patches directory, only for regular files.
        t.CheckOutputLines(
-               "NOTE: ~/category/package/Makefile: " +
+               "NOTE: ~/category/package: " +
                        "Please only commit changes that " +
                        "maintainer%example.org@localhost would approve.")
 }
diff -r a1184764d52a -r aad91c680264 pkgtools/pkglint/files/pkgsrc.go
--- a/pkgtools/pkglint/files/pkgsrc.go  Sat Mar 20 22:31:39 2021 +0000
+++ b/pkgtools/pkglint/files/pkgsrc.go  Sat Mar 20 23:32:43 2021 +0000
@@ -189,6 +189,7 @@
        if _, yyyy := match1(filename.Base().String(), `-(\d\d\d\d)$`); yyyy >= "2018" {
                year = yyyy
        }
+       thorough := G.CheckGlobal || year >= "2020" // For performance reasons
 
        latest := make(map[PkgsrcPath]*Change)
 
@@ -228,8 +229,10 @@
                        continue
                }
 
-               src.checkChangeVersion(change, latest, line)
-               src.checkChangeDate(filename, year, change, line, changes)
+               if thorough {
+                       src.checkChangeVersion(change, latest, line)
+                       src.checkChangeDate(filename, year, change, line, changes)
+               }
        }
 
        return changes
@@ -360,10 +363,39 @@
                author = f[n-2]
        }
 
-       if !matches(author, `^\[\w+$`) || !matches(date, `\d\d\d\d-\d\d-\d\d]$`) {
+       parseAuthorAndDate := func(author *string, date *string) bool {
+               alex := textproc.NewLexer(*author)
+               if !alex.SkipByte('[') {
+                       return false
+               }
+               *author = alex.NextBytesSet(textproc.AlnumU)
+               if !alex.EOF() {
+                       return false
+               }
+               dlex := textproc.NewLexer(*date)
+               if len(*date) == 11 &&
+                       dlex.NextByteSet(textproc.Digit) != -1 &&
+                       dlex.NextByteSet(textproc.Digit) != -1 &&
+                       dlex.NextByteSet(textproc.Digit) != -1 &&
+                       dlex.NextByteSet(textproc.Digit) != -1 &&
+                       dlex.SkipByte('-') &&
+                       dlex.NextByteSet(textproc.Digit) != -1 &&
+                       dlex.NextByteSet(textproc.Digit) != -1 &&
+                       dlex.SkipByte('-') &&
+                       dlex.NextByteSet(textproc.Digit) != -1 &&
+                       dlex.NextByteSet(textproc.Digit) != -1 &&
+                       dlex.SkipByte(']') &&
+                       dlex.EOF() {
+                       *date = (*date)[:10]
+                       return true
+               }
+
+               return false
+       }
+
+       if !parseAuthorAndDate(&author, &date) {
                return invalid()
        }
-       author, date = author[1:], date[:len(date)-1]
 
        switch {
        case
diff -r a1184764d52a -r aad91c680264 pkgtools/pkglint/files/varalignblock_test.go
--- a/pkgtools/pkglint/files/varalignblock_test.go      Sat Mar 20 22:31:39 2021 +0000
+++ b/pkgtools/pkglint/files/varalignblock_test.go      Sat Mar 20 23:32:43 2021 +0000
@@ -2948,6 +2948,57 @@
        vt.Run()
 }
 
+// This code comes from usr.bin/make/unit-tests/varcmd.mk.
+// Its purpose is unclear and irrelevant for this test.
+// The two .ifmake directives are unknown to pkglint since they are not
+// used in pkgsrc.
+// The variable assignments are not aligned.  That's good, but why?
+// It might be because of the unknown '.ifmake' or for a completely
+// different reason.
+//
+// Yes, it is because '.ifmake' is not a known directive, therefore
+// VaralignBlock.Process does not classify it as IsDirective and skips
+// the block.
+func (s *Suite) Test_VaralignBlock__unknown_line_format(c *check.C) {
+       vt := NewVaralignTester(s, c)
+       vt.Input(
+               ".ifmake two",
+               "# this should not work",
+               "FU+= oops",
+               "FOO+= oops",
+               "_FU:= ${FU}",
+               "_FOO:= ${FOO}",
+               "two: immutable",
+               "immutable:",
+               "\t:",
+               ".endif",
+               ".ifmake four",
+               "VAR=Internal",
+               ".MAKEOVERRIDES+= VAR",
+               ".endif")
+       vt.Diagnostics(
+               "ERROR: Makefile:1: Unknown Makefile line format: \".ifmake two\".",
+               "ERROR: Makefile:11: Unknown Makefile line format: \".ifmake four\".")
+       vt.Autofixes(
+               nil...)
+       vt.Fixed(
+               ".ifmake two",
+               "# this should not work",
+               "FU+= oops",
+               "FOO+= oops",
+               "_FU:= ${FU}",
+               "_FOO:= ${FOO}",
+               "two: immutable",
+               "immutable:",
+               "        :",
+               ".endif",
+               ".ifmake four",
+               "VAR=Internal",
+               ".MAKEOVERRIDES+= VAR",
+               ".endif")
+       vt.Run()
+}
+
 func (s *Suite) Test_VaralignBlock_Process__var_spaces7_value(c *check.C) {
        vt := NewVaralignTester(s, c)
        vt.Input(



Home | Main Index | Thread Index | Old Index