This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 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 23ce882  Fix wrong license identification (#55)
23ce882 is described below

commit 23ce8825c96cafa9fddc8ed4e5b4752a56a48ede
Author: kezhenxu94 <[email protected]>
AuthorDate: Fri Aug 13 19:26:14 2021 +0800

    Fix wrong license identification (#55)
---
 pkg/license/identifier.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pkg/license/identifier.go b/pkg/license/identifier.go
index 7864713..e74da75 100644
--- a/pkg/license/identifier.go
+++ b/pkg/license/identifier.go
@@ -70,7 +70,9 @@ func Identify(pkgPath, content string) (string, error) {
        content = Normalize(content)
 
        for name, license := range normalizedTemplates {
-               if strings.Contains(content, license) {
+               // Should not use `Contains` as a root LICENSE file may include 
other licenses the project uses,
+               // `Contains` would identify the last one license as the 
project's license.
+               if strings.HasPrefix(content, license) {
                        name = filepath.Base(name)
                        return strings.TrimSuffix(name, filepath.Ext(name)), nil
                }

Reply via email to