Skip to content

Commit

Permalink
Warn about pkgsrc-wip packages missing COMMIT_MSG
Browse files Browse the repository at this point in the history
Suggested by gdt@.
  • Loading branch information
rillig committed Jan 2, 2024
1 parent d2e3dfd commit 54c6899
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 9 deletions.
2 changes: 2 additions & 0 deletions v23/category_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\".",
Expand Down
15 changes: 13 additions & 2 deletions v23/changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion v23/lines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion v23/mklinechecker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
41 changes: 41 additions & 0 deletions v23/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)()
Expand Down
18 changes: 15 additions & 3 deletions v23/pkglint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions v23/pkgsrc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 54c6899

Please sign in to comment.