This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git
The following commit(s) were added to refs/heads/main by this push:
new 0d9c4df fix: return error in license check, add MIT header (#206)
0d9c4df is described below
commit 0d9c4df441f742f91faefd840d3ca48b49f28d2b
Author: kezhenxu94 <[email protected]>
AuthorDate: Sat Sep 13 14:31:45 2025 +0800
fix: return error in license check, add MIT header (#206)
---
assets/header-templates/MIT.txt | 21 +++++++++++++++++++++
pkg/deps/check.go | 19 ++++++-------------
2 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/assets/header-templates/MIT.txt b/assets/header-templates/MIT.txt
new file mode 100644
index 0000000..ac1159c
--- /dev/null
+++ b/assets/header-templates/MIT.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) [year] [owner]
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/pkg/deps/check.go b/pkg/deps/check.go
index 04e8301..f21c13b 100644
--- a/pkg/deps/check.go
+++ b/pkg/deps/check.go
@@ -21,6 +21,7 @@ import (
"fmt"
"math"
"path/filepath"
+ "slices"
"strings"
"gopkg.in/yaml.v3"
@@ -69,20 +70,16 @@ func Check(mainLicenseSpdxID string, config *ConfigDeps,
weakCompatible bool) er
report := Report{}
if err := Resolve(config, &report); err != nil {
- return nil
+ return err
}
return CheckWithMatrix(mainLicenseSpdxID, &matrix, &report,
weakCompatible)
}
func compare(list []string, spdxID string) bool {
- for _, com := range list {
- if spdxID == com {
- return true
- }
- }
- return false
+ return slices.Contains(list, spdxID)
}
+
func compareAll(spdxIDs []string, compare func(spdxID string) bool) bool {
for _, spdxID := range spdxIDs {
if !compare(spdxID) {
@@ -91,13 +88,9 @@ func compareAll(spdxIDs []string, compare func(spdxID
string) bool) bool {
}
return true
}
+
func compareAny(spdxIDs []string, compare func(spdxID string) bool) bool {
- for _, spdxID := range spdxIDs {
- if compare(spdxID) {
- return true
- }
- }
- return false
+ return slices.ContainsFunc(spdxIDs, compare)
}
func compareCompatible(matrix *CompatibilityMatrix, spdxID string,
weakCompatible bool) bool {