diff options
| author | Shulhan <ms@kilabit.info> | 2026-01-15 14:01:48 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-01-15 14:01:48 +0700 |
| commit | e662e3bc3c4aadf15a360495deaa86939ce84980 (patch) | |
| tree | 6c1476d2aa3cae1af9d833c74bbda99945115ec8 | |
| parent | 9a34a0e949a04c4b885314222e46c918a6f9f2dc (diff) | |
| download | spdxconv-e662e3bc3c4aadf15a360495deaa86939ce84980.tar.xz | |
all: add match-file-pattern for common files
The Makefile, go.mod, and go.sum are known file names.
| -rw-r--r-- | config.go | 11 | ||||
| -rw-r--r-- | report.go | 1 | ||||
| -rw-r--r-- | spdxconv_test.go | 14 | ||||
| -rw-r--r-- | testdata/scan/Makefile | 1 | ||||
| -rw-r--r-- | testdata/scan/go.mod | 1 | ||||
| -rw-r--r-- | testdata/scan/go.sum | 1 | ||||
| -rw-r--r-- | testdata/scan/spdxconv.cfg | 12 |
7 files changed, 38 insertions, 3 deletions
@@ -23,10 +23,18 @@ pattern = "^.*\\.(adoc|asciidoc|c|cc|cpp|cs|dart|go|h|hh|hpp|java|js|jsx|jsonc|k prefix = "//" [match-file-comment] +pattern = "^(.*/)?go.mod$" +prefix = "//" + +[match-file-comment] pattern = "^.*\\.(aff|bash|csh|dockerfile|env|gitignore|hcl|ipynb|make|pl|pm|py|ps1|rb|sh|tf|yaml|yml|zsh)$" prefix = "#" [match-file-comment] +pattern = "^(.*/)?[Mm]akefile$" +prefix = "#" + +[match-file-comment] pattern = "^.*\\.(css)$" prefix = "/*" suffix = "*/" @@ -53,6 +61,9 @@ prefix = "%" [match-file-comment] pattern = "^.*\\.(apk|app|bz2|csv|doc|docx|exe|gif|gz|jpeg|jpg|json|pdf|png|ppt|pptx|svg|svgz|tar|tgz|xls|xlsx|zip)$" +[match-file-comment] +pattern = "^(.*/)?go.sum$" + [match-license] pattern = "^(//+|#+|/\\*+|<!--+|--+)?\\s*(.*)governed by a BSD-style(.*)$" license_identifier = BSD-3-Clause @@ -178,6 +178,7 @@ func (rep *report) hasScanned(path string) bool { if ok { return true } + delete(rep.listUnknown, path) return false } diff --git a/spdxconv_test.go b/spdxconv_test.go index 85a5cf2..6c33645 100644 --- a/spdxconv_test.go +++ b/spdxconv_test.go @@ -41,9 +41,15 @@ func TestInit(t *testing.T) { Pattern: `^.*\.(adoc|asciidoc|c|cc|cpp|cs|dart|go|h|hh|hpp|java|js|jsx|jsonc|kt|kts|php|rs|sass|scss|swift|ts|tsx)$`, Prefix: `//`, }, { + Pattern: `^(.*/)?go.mod$`, + Prefix: `//`, + }, { Pattern: `^.*\.(aff|bash|csh|dockerfile|env|gitignore|hcl|ipynb|make|pl|pm|py|ps1|rb|sh|tf|yaml|yml|zsh)$`, Prefix: `#`, }, { + Pattern: `^(.*/)?[Mm]akefile$`, + Prefix: `#`, + }, { Pattern: `^.*\.(css)$`, Prefix: `/*`, Suffix: `*/`, @@ -62,6 +68,8 @@ func TestInit(t *testing.T) { Prefix: `%`, }, { Pattern: `^.*\.(apk|app|bz2|csv|doc|docx|exe|gif|gz|jpeg|jpg|json|pdf|png|ppt|pptx|svg|svgz|tar|tgz|xls|xlsx|zip)$`, + }, { + Pattern: `^(.*/)?go.sum$`, }}, MatchLicense: []*matchLicense{{ Pattern: `^(//+|#+|/\*+|<!--+|--+)?\s*(.*)governed by a BSD-style(.*)$`, @@ -134,6 +142,8 @@ func TestScan(t *testing.T) { // //spdxconv:regular // +Makefile,default,0,2025,default,0,#, +go.mod,default,0,2025,default,0,//, no_copyright_year.md,match,2,2026,default,0,<!--,--> po/included.go,match,1,2026,match,0,//, test.go,match,1,2022,match,0,//, @@ -143,6 +153,7 @@ test.sql,match,1,2022,match,0,--, // //spdxconv:binary // +go.sum,default,0,2025,default,0,, test.json,default,0,2026,default,0,, // //spdxconv:unknown @@ -343,7 +354,10 @@ func TestSPDXConv_scanDir(t *testing.T) { dir: `testdata/scan/`, exp: []string{ `.gitignore`, + `Makefile`, `a/b/.gitignore`, + `go.mod`, + `go.sum`, `no_copyright_year.md`, `po/included.go`, `test.go`, diff --git a/testdata/scan/Makefile b/testdata/scan/Makefile new file mode 100644 index 0000000..996cee9 --- /dev/null +++ b/testdata/scan/Makefile @@ -0,0 +1 @@ +# Empty. diff --git a/testdata/scan/go.mod b/testdata/scan/go.mod new file mode 100644 index 0000000..2bd6dce --- /dev/null +++ b/testdata/scan/go.mod @@ -0,0 +1 @@ +// Empty. diff --git a/testdata/scan/go.sum b/testdata/scan/go.sum new file mode 100644 index 0000000..2bd6dce --- /dev/null +++ b/testdata/scan/go.sum @@ -0,0 +1 @@ +// Empty. diff --git a/testdata/scan/spdxconv.cfg b/testdata/scan/spdxconv.cfg index 082d482..afbdb31 100644 --- a/testdata/scan/spdxconv.cfg +++ b/testdata/scan/spdxconv.cfg @@ -12,10 +12,18 @@ pattern = "^.*\\.(adoc|asciidoc|c|cc|cpp|cs|dart|go|h|hh|hpp|java|js|jsx|jsonc|k prefix = "//" [match-file-comment] +pattern = "^(.*/)?go.mod$" +prefix = "//" + +[match-file-comment] pattern = "^.*\\.(aff|bash|csh|dockerfile|env|gitignore|hcl|ipynb|make|pl|pm|py|ps1|rb|sh|tf|yaml|yml|zsh)$" prefix = "#" [match-file-comment] +pattern = "^(.*/)?[Mm]akefile$" +prefix = "#" + +[match-file-comment] pattern = "^.*\\.(css)$" prefix = "/*" suffix = "*/" @@ -42,10 +50,8 @@ prefix = "%" [match-file-comment] pattern = "^.*\\.(apk|app|bz2|csv|doc|docx|exe|gif|gz|jpeg|jpg|json|pdf|png|ppt|pptx|svg|svgz|tar|tgz|xls|xlsx|zip)$" -# File name that match with this pattern will have the ".license" file -# created. [match-file-comment] -pattern = "^.*\\.(apk|app|bz2|csv|doc|docx|exe|gif|gz|jpeg|jpg|json|pdf|png|ppt|pptx|svg|svgz|tar|tgz|xls|xlsx|zip)$" +pattern = "^(.*/)?go.sum$" [match-license] pattern = "^(//+|#+|/\\*+|<!--+|--+)?\\s*(.*)governed by a BSD-style(.*)$" |
