pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/pkglint



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sat Mar 20 23:32:43 UTC 2021

Modified Files:
        pkgsrc/pkgtools/pkglint: Makefile
        pkgsrc/pkgtools/pkglint/files: mklines.go package.go package_test.go
            pkgsrc.go varalignblock_test.go

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.679 -r1.680 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.72 -r1.73 pkgsrc/pkgtools/pkglint/files/mklines.go
cvs rdiff -u -r1.96 -r1.97 pkgsrc/pkgtools/pkglint/files/package.go
cvs rdiff -u -r1.80 -r1.81 pkgsrc/pkgtools/pkglint/files/package_test.go
cvs rdiff -u -r1.58 -r1.59 pkgsrc/pkgtools/pkglint/files/pkgsrc.go
cvs rdiff -u -r1.16 -r1.17 \
    pkgsrc/pkgtools/pkglint/files/varalignblock_test.go

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/pkglint/Makefile
diff -u pkgsrc/pkgtools/pkglint/Makefile:1.679 pkgsrc/pkgtools/pkglint/Makefile:1.680
--- pkgsrc/pkgtools/pkglint/Makefile:1.679      Fri Mar 19 17:37:04 2021
+++ pkgsrc/pkgtools/pkglint/Makefile    Sat Mar 20 23:32:43 2021
@@ -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/}

Index: pkgsrc/pkgtools/pkglint/files/mklines.go
diff -u pkgsrc/pkgtools/pkglint/files/mklines.go:1.72 pkgsrc/pkgtools/pkglint/files/mklines.go:1.73
--- pkgsrc/pkgtools/pkglint/files/mklines.go:1.72       Sun Jun  7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/mklines.go    Sat Mar 20 23:32:43 2021
@@ -40,6 +40,8 @@ type MkLines struct {
        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

Index: pkgsrc/pkgtools/pkglint/files/package.go
diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.96 pkgsrc/pkgtools/pkglint/files/package.go:1.97
--- pkgsrc/pkgtools/pkglint/files/package.go:1.96       Wed Jul 22 19:26:30 2020
+++ pkgsrc/pkgtools/pkglint/files/package.go    Sat Mar 20 23:32:43 2021
@@ -1473,7 +1473,7 @@ func (pkg *Package) checkOwnerMaintainer
                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\",",

Index: pkgsrc/pkgtools/pkglint/files/package_test.go
diff -u pkgsrc/pkgtools/pkglint/files/package_test.go:1.80 pkgsrc/pkgtools/pkglint/files/package_test.go:1.81
--- pkgsrc/pkgtools/pkglint/files/package_test.go:1.80  Wed Jul  1 13:17:41 2020
+++ pkgsrc/pkgtools/pkglint/files/package_test.go       Sat Mar 20 23:32:43 2021
@@ -3190,10 +3190,32 @@ func (s *Suite) Test_Package_checkOwnerM
        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 @@ func (s *Suite) Test_Package_checkOwnerM
        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 @@ func (s *Suite) Test_Package_checkOwnerM
 
        // 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.")
 }

Index: pkgsrc/pkgtools/pkglint/files/pkgsrc.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.58 pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.59
--- pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.58        Tue Oct  6 18:40:50 2020
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc.go     Sat Mar 20 23:32:43 2021
@@ -189,6 +189,7 @@ func (src *Pkgsrc) loadDocChangesFromFil
        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 @@ func (src *Pkgsrc) loadDocChangesFromFil
                        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 @@ func (*Pkgsrc) parseDocChange(line *Line
                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

Index: pkgsrc/pkgtools/pkglint/files/varalignblock_test.go
diff -u pkgsrc/pkgtools/pkglint/files/varalignblock_test.go:1.16 pkgsrc/pkgtools/pkglint/files/varalignblock_test.go:1.17
--- pkgsrc/pkgtools/pkglint/files/varalignblock_test.go:1.16    Sun Mar 15 11:31:24 2020
+++ pkgsrc/pkgtools/pkglint/files/varalignblock_test.go Sat Mar 20 23:32:43 2021
@@ -2948,6 +2948,57 @@ func (s *Suite) Test_VaralignBlock__righ
        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