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 19.4.5



details:   https://anonhg.NetBSD.org/pkgsrc/rev/da43f520e14e
branches:  trunk
changeset: 422301:da43f520e14e
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Jan 23 21:56:50 2020 +0000

description:
pkgtools/pkglint: update to 19.4.5

Changes since 19.4.4:

Fixed automatic replacement from http SourceForge URLs to their https
counterparts. According to their official documentation, the https URLs
are not on the same hosts as before, but on *.sourceforge.io.

diffstat:

 pkgtools/pkglint/Makefile                   |   4 +-
 pkgtools/pkglint/files/autofix_test.go      |  34 +++++++++++++++++++++++++++++
 pkgtools/pkglint/files/vartypecheck.go      |   7 +++++-
 pkgtools/pkglint/files/vartypecheck_test.go |  17 ++++++++++++++
 4 files changed, 59 insertions(+), 3 deletions(-)

diffs (100 lines):

diff -r ca180790e7a8 -r da43f520e14e pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Thu Jan 23 18:36:15 2020 +0000
+++ b/pkgtools/pkglint/Makefile Thu Jan 23 21:56:50 2020 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.626 2020/01/18 21:56:09 rillig Exp $
+# $NetBSD: Makefile,v 1.627 2020/01/23 21:56:50 rillig Exp $
 
-PKGNAME=       pkglint-19.4.4
+PKGNAME=       pkglint-19.4.5
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r ca180790e7a8 -r da43f520e14e pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go    Thu Jan 23 18:36:15 2020 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go    Thu Jan 23 21:56:50 2020 +0000
@@ -746,6 +746,40 @@
                0, 20, "?", "+=")
 }
 
+func (s *Suite) Test_Autofix_ReplaceAt__only(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpCommandLine("--only", "specific", "--autofix")
+       mklines := t.SetUpFileMkLines("filename.mk",
+               "# comment")
+
+       mklines.ForEach(func(mkline *MkLine) {
+               // FIXME
+               // The modifications from this replacement are not supposed
+               // to be saved to the file.
+               // They should only be applied to the in-memory copy.
+               fix := mkline.Autofix()
+               fix.Warnf("Warning.")
+               fix.ReplaceAt(0, 0, "# ", "COMMENT=\t")
+               fix.Apply()
+
+               // This autofix marks the file's lines as changed.
+               // Without it, SaveAutofixChanges would not have any effect.
+               fix = mkline.Autofix()
+               fix.Warnf("A specific warning.")
+               fix.Replace("comment", "remark")
+               fix.Apply()
+       })
+       mklines.SaveAutofixChanges()
+
+       t.CheckOutputLines(
+               "AUTOFIX: ~/filename.mk:1: Replacing \"comment\" with \"remark\".")
+       t.CheckFileLines("filename.mk",
+               // FIXME: The "COMMENT=" must not appear here since it
+               //  was supposed to be ignored by the --only option.
+               "COMMENT=\tremark")
+}
+
 func (s *Suite) Test_Autofix_InsertBefore(c *check.C) {
        t := s.Init(c)
 
diff -r ca180790e7a8 -r da43f520e14e pkgtools/pkglint/files/vartypecheck.go
--- a/pkgtools/pkglint/files/vartypecheck.go    Thu Jan 23 18:36:15 2020 +0000
+++ b/pkgtools/pkglint/files/vartypecheck.go    Thu Jan 23 21:56:50 2020 +0000
@@ -729,7 +729,12 @@
        fix := cv.Autofix()
        fix.Warnf("HOMEPAGE should use https instead of http.")
        if supportsHttps {
-               fix.Replace("http", "https")
+               if hasAnySuffix(host, "sourceforge.net") {
+                       // See https://sourceforge.net/p/forge/documentation/Custom%20VHOSTs/
+                       fix.Replace("http://"+host, "https://"+replaceAll(host, `\.net`, ".io"))
+               } else {
+                       fix.Replace("http", "https")
+               }
        }
        fix.Explain(
                "To provide secure communication by default,",
diff -r ca180790e7a8 -r da43f520e14e pkgtools/pkglint/files/vartypecheck_test.go
--- a/pkgtools/pkglint/files/vartypecheck_test.go       Thu Jan 23 18:36:15 2020 +0000
+++ b/pkgtools/pkglint/files/vartypecheck_test.go       Thu Jan 23 21:56:50 2020 +0000
@@ -992,6 +992,23 @@
                "WARN: filename.mk:3: HOMEPAGE should use https instead of http.",
                "WARN: filename.mk:4: HOMEPAGE should use https instead of http.",
                "WARN: filename.mk:7: HOMEPAGE should use https instead of http.")
+
+       t.SetUpCommandLine("--autofix")
+       vt.Values(
+               "http://www.gnustep.org/";,
+               "http://www.pkgsrc.org/";,
+               "http://project.sourceforge.net/";,
+               "http://sf.net/p/project/";,
+               "http://example.org/ # doesn't support https",
+               "http://example.org/ # only supports http",
+               "http://asf.net/";)
+
+       // www.gnustep.org does not support https at all.
+       // www.pkgsrc.org is not in the (short) list of known https domains,
+       // therefore pkglint does not dare to change it automatically.
+       vt.Output(
+               "AUTOFIX: filename.mk:13: Replacing \"http://project.sourceforge.net\"; with \"https://project.sourceforge.io\".";,
+               "AUTOFIX: filename.mk:14: Replacing \"http\" with \"https\".")
 }
 
 func (s *Suite) Test_VartypeCheck_IdentifierDirect(c *check.C) {



Home | Main Index | Thread Index | Old Index