diff options
| author | Shulhan <ms@kilabit.info> | 2026-01-08 04:29:18 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-01-08 04:29:18 +0700 |
| commit | 2f6ebacaea7851be5c17a970514769dd3e9735e9 (patch) | |
| tree | d34bcd794ae3946d1a5446e7554ec3cfeaa7c40b /testdata | |
| parent | 161049a3996c574d521d6d3df55998028eb111c0 (diff) | |
| download | spdxconv-2f6ebacaea7851be5c17a970514769dd3e9735e9.tar.xz | |
all: implement conversion for SPDX-License-Identifier
If the file contains "SPDX-License-Identifier", it will not modify it.
The program will move the identifier to the top of file after shebang.
If the spdxconv.cfg contains match-license, and the pattern match with
one of the line in the file, it will use the license_identifier instead
of default one and insert it at the top, after shebang.
If the files does not contains the identifier, it will insert new one
based on default value in spdxconv.cfg file.
Diffstat (limited to 'testdata')
| -rw-r--r-- | testdata/file/.gitignore | 2 | ||||
| -rw-r--r-- | testdata/file_test.txt | 108 | ||||
| -rw-r--r-- | testdata/scan/spdxconv.cfg | 4 |
3 files changed, 114 insertions, 0 deletions
diff --git a/testdata/file/.gitignore b/testdata/file/.gitignore new file mode 100644 index 0000000..1e37400 --- /dev/null +++ b/testdata/file/.gitignore @@ -0,0 +1,2 @@ +/** +!/.gitignore diff --git a/testdata/file_test.txt b/testdata/file_test.txt new file mode 100644 index 0000000..dad7b85 --- /dev/null +++ b/testdata/file_test.txt @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2025 M. Shulhan <ms@kilabit.info> + +>>> spdxconv.cfg +# SPDX-License-Identifier: BSD-3-Clause +# SPDX-FileCopyrightText: 2025 M. Shulhan <ms@kilabit.info> + +[default] +license_identifier = GPL-3.0-only +file_copyright_text = M. Shulhan <ms@kilabit.info> + +[match-license] +pattern = "^(//+|#+)\\s+(.*)governed by a BSD-style(.*)$" +license_identifier = BSD-3-Clause +delete_match = true +delete_line_pattern = "^(//+|#+)\\s*$" +delete_line_pattern = "^(//+|#+)\\s+license that(.*)$" + +[match-copyright] +pattern = "^(//+|#+)\\s+Copyright\\s+(?<year>\\d{4}),?\\s+(?<holder>.*)\\s+<*(?<email>.*)>.*$" + +>>> without_spdx_license_id.txt +1 +2 +3 + +<<< without_spdx_license_id.txt +SPDX-License-Identifier: GPL-3.0-only +1 +2 +3 + +>>> with_spdx_at_bottom.txt +1 +2 +3 +// SPDX-License-Identifier: GPL-3.0-only + +<<< with_spdx_at_bottom.txt +// SPDX-License-Identifier: GPL-3.0-only + +1 +2 +3 + +>>> with_spdx_license_id_only.txt +// SPDX-License-Identifier: GPL-3.0-only +1 +2 +3 + +<<< with_spdx_license_id_only.txt +// SPDX-License-Identifier: GPL-3.0-only + +1 +2 +3 + +>>> with_no_order.txt +// SPDX-FileCopyrightText: 2025 M. Shulhan <ms@kilabit.info> +// SPDX-License-Identifier: BSD-3-Clause + +1 +2 +3 + +<<< with_no_order.txt +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2025 M. Shulhan <ms@kilabit.info> + +1 +2 +3 + +>>> with_match_license.txt +// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +1 +2 +3 + +<<< with_match_license.txt +// SPDX-License-Identifier: BSD-3-Clause +// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. + +1 +2 +3 + +>>> with_match_license_bottom.txt +1 +2 +3 + +// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +<<< with_match_license_bottom.txt +// SPDX-License-Identifier: BSD-3-Clause + +1 +2 +3 + +// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved. diff --git a/testdata/scan/spdxconv.cfg b/testdata/scan/spdxconv.cfg new file mode 100644 index 0000000..b4e39c6 --- /dev/null +++ b/testdata/scan/spdxconv.cfg @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2025 M. Shulhan <ms@kilabit.info> + +[default] |
