From 54c68998976a960c9aa8bbf6042dcb43df43987c Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Tue, 2 Jan 2024 18:18:05 +0100 Subject: [PATCH] Warn about pkgsrc-wip packages missing COMMIT_MSG Suggested by gdt@. --- v23/category_test.go | 2 ++ v23/changes_test.go | 15 ++++++++++++-- v23/lines_test.go | 4 +++- v23/mklinechecker_test.go | 4 +++- v23/package.go | 41 +++++++++++++++++++++++++++++++++++++++ v23/pkglint_test.go | 18 ++++++++++++++--- v23/pkgsrc_test.go | 7 +++++-- 7 files changed, 82 insertions(+), 9 deletions(-) diff --git a/v23/category_test.go b/v23/category_test.go index 8d01c235..93e73dea 100644 --- a/v23/category_test.go +++ b/v23/category_test.go @@ -504,6 +504,8 @@ func (s *Suite) Test_CheckPackageDirCollision__wip(c *check.C) { G.Check(".") t.CheckOutputLines( + "WARN: COMMIT_MSG: Every work-in-progress "+ + "package should have a COMMIT_MSG file.", "ERROR: ../../category/Makefile:5: "+ "On case-insensitive file systems, "+ "\"PACKAGE\" is the same as \"package\".", diff --git a/v23/changes_test.go b/v23/changes_test.go index 6944b058..ab7bdca6 100644 --- a/v23/changes_test.go +++ b/v23/changes_test.go @@ -120,7 +120,12 @@ func (s *Suite) Test_Changes_parseFile__wip_suppresses_warnings(c *check.C) { t.Main("-Cglobal", "-Wall", "wip/package") t.CheckOutputLines( - "Looks fine.") + "WARN: ~/wip/package/COMMIT_MSG: Every work-in-progress "+ + "package should have a COMMIT_MSG file.", + "1 warning found.", + "(Run \"pkglint -e -Cglobal -Wall ~/wip/package\" "+ + "to show explanations.)", + ) } // When a single package is checked, only the lines from doc/CHANGES @@ -554,7 +559,13 @@ func (s *Suite) Test_Changes_checkRemovedAfterLastFreeze__wip(c *check.C) { // write access to main pkgsrc, and therefore cannot fix doc/CHANGES. t.CheckOutputLines( - "Looks fine.") + "WARN: ~/wip/package/COMMIT_MSG: Every work-in-progress "+ + "package should have a COMMIT_MSG file.", + "", + "1 warning found.", + "(Run \"pkglint -e -Wall --source ~/wip/package\" "+ + "to show explanations.)", + ) } func (s *Suite) Test_Change_Version(c *check.C) { diff --git a/v23/lines_test.go b/v23/lines_test.go index 4264708d..41a6ef2e 100644 --- a/v23/lines_test.go +++ b/v23/lines_test.go @@ -128,7 +128,9 @@ func (s *Suite) Test_Lines_CheckCvsID__wip(c *check.C) { "NOTE: ~/wip/package/file1.mk:1: Expected exactly \"# $"+"NetBSD$\".", "ERROR: ~/wip/package/file3.mk:1: Expected \"# $"+"NetBSD$\".", "ERROR: ~/wip/package/file4.mk:1: Expected \"# $"+"NetBSD$\".", - "ERROR: ~/wip/package/file5.mk:1: Expected \"# $"+"NetBSD$\".") + "ERROR: ~/wip/package/file5.mk:1: Expected \"# $"+"NetBSD$\".", + "WARN: ~/wip/package/COMMIT_MSG: Every work-in-progress "+ + "package should have a COMMIT_MSG file.") G.Logger.Opts.Autofix = true diff --git a/v23/mklinechecker_test.go b/v23/mklinechecker_test.go index ca54031c..f276cdd4 100644 --- a/v23/mklinechecker_test.go +++ b/v23/mklinechecker_test.go @@ -886,7 +886,9 @@ func (s *Suite) Test_MkLineChecker_CheckRelativePath__wip_mk(c *check.C) { "WARN: ~/wip/package/Makefile:20: References to the pkgsrc-wip "+ "infrastructure should look like \"../../wip/mk\", not \"../mk\".", "WARN: ~/wip/package/Makefile:21: References to other packages "+ - "should look like \"../../category/package\", not \"../package\".") + "should look like \"../../category/package\", not \"../package\".", + "WARN: ~/wip/package/COMMIT_MSG: Every work-in-progress "+ + "package should have a COMMIT_MSG file.") } func (s *Suite) Test_MkLineChecker_CheckPackageDir(c *check.C) { diff --git a/v23/package.go b/v23/package.go index 1fd1e592..1928922c 100644 --- a/v23/package.go +++ b/v23/package.go @@ -624,6 +624,7 @@ func (pkg *Package) check(filenames []CurrPath, mklines, allLines *MkLines) { pkg.checkDistfilesInDistinfo(allLines) pkg.checkPkgConfig(allLines) + pkg.checkWipCommitMsg() } func (pkg *Package) checkDescr(filenames []CurrPath, mklines *MkLines) { @@ -703,6 +704,46 @@ func (pkg *Package) checkPkgConfig(allLines *MkLines) { "directory will be empty and pkg-config will not find anything.") } +func (pkg *Package) checkWipCommitMsg() { + if !G.Wip { + return + } + file := pkg.File("COMMIT_MSG") + lines := Load(file, NotEmpty) + if lines == nil { + line := NewLineWhole(file) + line.Warnf("Every work-in-progress package should have a COMMIT_MSG file.") + line.Explain( + "A wip package should have a file COMMIT_MSG", + "that contains exactly the text", + "that should be used for importing the package to main pkgsrc,", + "or for updating the main pkgsrc package from the wip version.", + "Someone with main pkgsrc write access should be able", + "to simply run 'cvs commit -F COMMIT_MSG'.", + "", + "Line 1 should have one of these forms:", + "\tcategory/pkgpath: Add foo version 1.2.3", + "\tcategory/pkgpath: Update foo to 4.5.6", + "", + "The next paragraph gives credit", + "to the work-in-progress packager, such as:", + "\tPackaged in wip by Alyssa P. Hacker", + "\tUpdate prepared in wip by Ben Bitdiddle", + "", + "The next paragraph describes the pkgsrc-specific", + "packaging changes, if any.", + "", + "The next paragraph summarizes the upstream changes", + "on a high level.", + "In packages following the GNU Coding Standards,", + "these changes are in the NEWS file, see", + "https://www.gnu.org/prep/standards/html_node/NEWS-File.html.", + "", + "See https://www.pkgsrc.org/wip/users/.") + return + } +} + func (pkg *Package) checkfilePackageMakefile(filename CurrPath, mklines *MkLines, allLines *MkLines) { if trace.Tracing { defer trace.Call(filename)() diff --git a/v23/pkglint_test.go b/v23/pkglint_test.go index 225dff9b..091b8ec4 100644 --- a/v23/pkglint_test.go +++ b/v23/pkglint_test.go @@ -1094,14 +1094,24 @@ func (s *Suite) Test_Pkglint_checkReg__readme_and_todo(c *check.C) { t.CheckOutputLines( "ERROR: category/package/TODO: Packages in main pkgsrc must not have a TODO file.", - "1 error found.") + "WARN: wip/package/COMMIT_MSG: Every work-in-progress "+ + "package should have a COMMIT_MSG file.", + "1 error and 1 warning found.", + "(Run \"pkglint -e category/package wip/package\" "+ + "to show explanations.)", + ) t.Main("--import", "category/package", "wip/package") t.CheckOutputLines( "ERROR: category/package/TODO: Packages in main pkgsrc must not have a TODO file.", "ERROR: wip/package/TODO: Must be cleaned up before committing the package.", - "2 errors found.") + "WARN: wip/package/COMMIT_MSG: Every work-in-progress "+ + "package should have a COMMIT_MSG file.", + "2 errors and 1 warning found.", + "(Run \"pkglint -e --import category/package wip/package\" "+ + "to show explanations.)", + ) } func (s *Suite) Test_Pkglint_checkReg__unknown_file_in_patches(c *check.C) { @@ -1195,7 +1205,9 @@ func (s *Suite) Test_Pkglint_checkReg__wip_commit_message(c *check.C) { G.Check(".") - t.CheckOutputEmpty() + t.CheckOutputLines( + "WARN: COMMIT_MSG: Every work-in-progress package " + + "should have a COMMIT_MSG file.") } func (s *Suite) Test_Pkglint_checkReg__file_ignored_by_CVS(c *check.C) { diff --git a/v23/pkgsrc_test.go b/v23/pkgsrc_test.go index 738ccf45..5a0b5be0 100644 --- a/v23/pkgsrc_test.go +++ b/v23/pkgsrc_test.go @@ -147,8 +147,11 @@ func (s *Suite) Test_Pkgsrc_parseSuggestedUpdates__wip(c *check.C) { G.Check(pkg) t.CheckOutputLines( - "WARN: ~/wip/package/Makefile:3: " + - "This package should be updated to 1.13 (cool new features; see ../../wip/TODO:5).") + "WARN: ~/wip/package/Makefile:3: "+ + "This package should be updated to 1.13 "+ + "(cool new features; see ../../wip/TODO:5).", + "WARN: ~/wip/package/COMMIT_MSG: Every work-in-progress "+ + "package should have a COMMIT_MSG file.") } func (s *Suite) Test_Pkgsrc_parseSuggestedUpdates__parse_errors(c *check.C) {