From 2cda75bc9385da199b4db5f6cc2692bfd694fcf1 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Mon, 5 Jan 2026 22:35:40 +0700 Subject: spdxconv: tool to convert license and copyright to SPDX format This is the initial implementation, work in progress, with the following functions, * loading the spdxconv.cfg file * scanning list of files to be converted * detect .git repository and exclude files ignored by .gitignore No conversion logic is implemented yet. --- testdata/New_test.txt | 36 ++++++++++++++++++++++++++ testdata/loadConfig/config_exists/spdxconv.cfg | 14 ++++++++++ testdata/scan/.gitignore | 4 +++ testdata/scan/test.go | 3 +++ testdata/scan/test.html | 5 ++++ testdata/scan/test.sh | 3 +++ 6 files changed, 65 insertions(+) create mode 100644 testdata/New_test.txt create mode 100644 testdata/loadConfig/config_exists/spdxconv.cfg create mode 100644 testdata/scan/.gitignore create mode 100644 testdata/scan/test.go create mode 100644 testdata/scan/test.html create mode 100644 testdata/scan/test.sh (limited to 'testdata') diff --git a/testdata/New_test.txt b/testdata/New_test.txt new file mode 100644 index 0000000..2b718d3 --- /dev/null +++ b/testdata/New_test.txt @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2025 M. Shulhan + +>>> .git/config +# Copyright 2022, Shulhan . All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +>>> .gitignore +node_modules/ +*.html +!test.html +vendor/ + +>>> node_modules/dummy +Dummy content for node_modules directory. + +>>> test.go +// Copyright 2022, Shulhan . All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +>>> test.html + + +>>> test.sh +# Copyright 2022, Shulhan . All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +>>> vendor/dummy +Dummy content for vendor directory. diff --git a/testdata/loadConfig/config_exists/spdxconv.cfg b/testdata/loadConfig/config_exists/spdxconv.cfg new file mode 100644 index 0000000..e4edf89 --- /dev/null +++ b/testdata/loadConfig/config_exists/spdxconv.cfg @@ -0,0 +1,14 @@ +[default] +license_identifier = GPL-3.0-only +file_copyright_text = Author +max_line_match = 10 + +[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+(?\\d{4},?\\s+(?.*)\\s+<*(?.*)>.*$" diff --git a/testdata/scan/.gitignore b/testdata/scan/.gitignore new file mode 100644 index 0000000..746a46e --- /dev/null +++ b/testdata/scan/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +*.html +!test.html +vendor/ \ No newline at end of file diff --git a/testdata/scan/test.go b/testdata/scan/test.go new file mode 100644 index 0000000..46e2bd9 --- /dev/null +++ b/testdata/scan/test.go @@ -0,0 +1,3 @@ +// Copyright 2022, Shulhan . All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. \ No newline at end of file diff --git a/testdata/scan/test.html b/testdata/scan/test.html new file mode 100644 index 0000000..da2491e --- /dev/null +++ b/testdata/scan/test.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/testdata/scan/test.sh b/testdata/scan/test.sh new file mode 100644 index 0000000..8fd6949 --- /dev/null +++ b/testdata/scan/test.sh @@ -0,0 +1,3 @@ +# Copyright 2022, Shulhan . All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. \ No newline at end of file -- cgit v1.3-5-g9baa