diff options
| -rw-r--r-- | README.md | 26 | ||||
| -rw-r--r-- | config.go | 2 | ||||
| -rw-r--r-- | file.go | 5 | ||||
| -rw-r--r-- | testdata/Apply_test.txt | 7 | ||||
| -rw-r--r-- | testdata/scan/spdxconv.cfg | 1 |
5 files changed, 31 insertions, 10 deletions
@@ -69,6 +69,7 @@ following content, [default] license_identifier = +copyright_year = file_copyright_text = max_line_match = 10 @@ -134,11 +135,26 @@ affect the program during scan and apply. ### default section -This section define the default license identifier and copyright text to be -inserted into file if no `match-license` or `match-copyright` found in the -file. -You should fill the `license_identifier` and `file_copyright_text` before -continue running the program. +This section define the default license identifier, year, and copyright text +to be inserted into file if no `match-license` or `match-copyright` found in +the file. + +The `license_identifier` set the default license using one of SPDX license +identifier from [https://spdx.org/licenses/]() . +For example, `GPL-3.0-only` for GNU General Public License v3.0 only. + +The `copyright_year` set the default year to be used in +`SPDX-FileCopyrightText`. +The year can be a single year (for example "2026"), range of year (for +example, "2000-2026"), or list of year with comma separated (for example, +"2000,2001,2026"); as long as there is no space in between. + +The `file_copyright_text` set the default author and contact in +`SPDX-FileCopyrightText`. +For example, "John Doe <john.doe@example>". + +You should fill the `license_identifier`, `copyright_year`, and +`file_copyright_text` before continue running the program. The `max_line_match` define the number of lines to be searched at the top and bottom of file for `SPDX-*` identifiers, `match-license`, and @@ -14,6 +14,7 @@ var configTemplate string = `# SPDX-License-Identifier: CC0-1.0 [default] license_identifier = +copyright_year = file_copyright_text = max_line_match = 10 @@ -63,6 +64,7 @@ pattern = "^(//+|#+)\\s+Copyright\\s+(?<year>\\d{4}),?\\s+(?<author>.*)\\s+<*(?< type config struct { LicenseIdentifier string `ini:"default::license_identifier"` + CopyrightYear string `ini:"default::copyright_year"` FileCopyrightText string `ini:"default::file_copyright_text"` MatchFileComment []*matchFileComment `ini:"match-file-comment"` @@ -240,8 +240,9 @@ func (f *file) apply(conv *SPDXConv) (err error) { f.topLines = slices.Insert(f.topLines, f.idxLicenseID, rawline) if f.copyrightYear == valUnknown { - f.copyrightYear = `` - } else { + f.copyrightYear = conv.cfg.CopyrightYear + } + if f.copyrightYear != `` { f.copyrightYear += ` ` } // REUSE-IgnoreStart diff --git a/testdata/Apply_test.txt b/testdata/Apply_test.txt index 43360b4..611f654 100644 --- a/testdata/Apply_test.txt +++ b/testdata/Apply_test.txt @@ -9,6 +9,7 @@ [default] license_identifier = GPL-3.0-only +copyright_year = 2026 file_copyright_text = M. Shulhan <ms@kilabit.info> [match-file-comment] @@ -61,7 +62,7 @@ pattern = "^(//+|#+)\\s+Copyright\\s+(?<year>\\d{4}),?\\s+(?<author>.*)\\s+<*(?< <<< without_spdx_license_id.go // SPDX-License-Identifier: GPL-3.0-only -// SPDX-FileCopyrightText: M. Shulhan <ms@kilabit.info> +// SPDX-FileCopyrightText: 2026 M. Shulhan <ms@kilabit.info> 1 2 @@ -75,7 +76,7 @@ pattern = "^(//+|#+)\\s+Copyright\\s+(?<year>\\d{4}),?\\s+(?<author>.*)\\s+<*(?< <<< with_spdx_at_bottom.go // SPDX-License-Identifier: GPL-3.0-only -// SPDX-FileCopyrightText: M. Shulhan <ms@kilabit.info> +// SPDX-FileCopyrightText: 2026 M. Shulhan <ms@kilabit.info> 1 2 @@ -89,7 +90,7 @@ pattern = "^(//+|#+)\\s+Copyright\\s+(?<year>\\d{4}),?\\s+(?<author>.*)\\s+<*(?< <<< with_spdx_license_id_only.go // SPDX-License-Identifier: GPL-3.0-only -// SPDX-FileCopyrightText: M. Shulhan <ms@kilabit.info> +// SPDX-FileCopyrightText: 2026 M. Shulhan <ms@kilabit.info> 1 2 diff --git a/testdata/scan/spdxconv.cfg b/testdata/scan/spdxconv.cfg index d317d64..59ae864 100644 --- a/testdata/scan/spdxconv.cfg +++ b/testdata/scan/spdxconv.cfg @@ -3,6 +3,7 @@ [default] license_identifier = GPL-3.0-only +copyright_year = 2026 file_copyright_text = Author <contact@email.local> max_line_match = 10 |
